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
_create: function () { | |
... | |
this._on(this.elTitle, { | |
click: "_titleClick" // Note: function name must be passed as a string! | |
}); | |
}, | |
_titleClick: function (event) { | |
console.log(this); // 'this' is now the widget instance. | |
}, |
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", { | |
// the rest of the clicker is omitted | |
destroy: function () { | |
this.element.text(""); | |
// Call the base destroy function. | |
$.Widget.prototype.destroy.call(this); |
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> | |
var theClicker = $("#myClicker").clicker({ | |
isUpdated: function (event, data) { | |
console.log("isOneHundredOne"); | |
alert("Is " + data.myValue); | |
} | |
}); | |
theClicker.clicker({ newValue: 101 }); | |
</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
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
(function ($) { | |
$.widget("custom.clicker", { | |
// Default options. | |
options: { | |
startingValue: 0, | |
_currentValue : 0 | |
}, | |
// _create and other methods to access properties ommitted .. |
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 |
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 | |
}, | |
_create: function () { | |
var startingValue = this.options.startingValue; |
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", { | |
_create: function () { | |
var startingValue = this.options.startingValue; | |
this.element.text("The starting value is " + startingValue); | |
} | |
}); | |
}(jQuery)); |
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( { | |
startingValue: 4 | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Clicker</title> | |
</head> | |
<body> | |
<div id="myClicker"> | |
</div> | |
<script src="Scripts/jquery-2.1.3.js"></script> |