Skip to content

Instantly share code, notes, and snippets.

@devdays
Created February 23, 2015 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/12ae2f0be8125827c1e1 to your computer and use it in GitHub Desktop.
Save devdays/12ae2f0be8125827c1e1 to your computer and use it in GitHub Desktop.
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