Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting options
myClicker.clicker( { currentValue: 100 } );
newCurrentValue = myClicker.clicker("currentValue");
alert(newCurrentValue);
setting [currentValue]: 100
update
(function ($) {
$.widget("custom.clicker", {
// Default options.
options: {
startingValue: 0,
_currentValue : 0
},
// code omitted
_setOption: function (key, value) {
console.log("setting [" + key + "]: " + value);
this.options[key] = value;
// calls my "private" method
this._update();
},
// Wiget Factory makes methods that begin with _ private and
// are not exposed to consumers
_update: function () {
console.log("update");
this.element.text("The current value is " + this.options._currentValue);
}
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment