Skip to content

Instantly share code, notes, and snippets.

@devdays
Created February 23, 2015 21: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/96b925ac490a0014f578 to your computer and use it in GitHub Desktop.
Save devdays/96b925ac490a0014f578 to your computer and use it in GitHub Desktop.
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