Created
February 23, 2015 21:10
-
-
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
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
<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> |
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
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