How to save an internal property in jquery-ui widget?

I am programming a new jquery-ui widget from scratch. I found an official document on how the widget factory document works. ( http://jqueryui.com/demos/widget/ )

The widget itself works great. Now I want to keep some values ​​inside - is there a preferred way to do this?
All properties declared in parameters are public, I think.

Thank you for your help!

+5
source share
1 answer

Just use the old properties on this. For example, a basic widget would look something like this:

$.widget('some_name', {
    options: { /* ... */ },
    _create: function() {
        // ...
        this.internal_value = 11;
        // ...
    },
    frobnicate_by: function(this_much) {
        this.internal_value += this_much;
    }
    // ...
});

this . , this.internal_value 11 $(s).some_name('frobnicate_by', 23) internal_value.

, , this.changer.

options , , - . , ; factory , OO .

+8

All Articles