Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Getting the startingValue, getting or setting the currentValue in a jQuery UI Widget
<script>
// initializing the startingValue
var myClicker = $("#myClicker").clicker({ startingValue: 4 });
// getting the startingValue
alert(myClicker.clicker("startingValue"));
// setting the currentValue
myClicker.clicker("currentValue", 7);
// getting the currentValue
var newCurrentValue = myClicker.clicker("currentValue");
alert(newCurrentValue);
</script>
startingValue: function() {
return this.options.startingValue;
},
currentValue: function(currentValue) {
// No value passed, act as a getter.
if (currentValue === undefined) {
return this.options._currentValue;
// Value passed, act as a setter.
} else {
this.options._currentValue = currentValue;
this.element.text("The current value is " + this.options._currentValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment