Created
February 23, 2015 23:10
-
-
Save devdays/12ae2f0be8125827c1e1 to your computer and use it in GitHub Desktop.
Setting options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myClicker.clicker( { currentValue: 100 } ); | |
newCurrentValue = myClicker.clicker("currentValue"); | |
alert(newCurrentValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setting [currentValue]: 100 | |
update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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