Calling a Trigger
<script> | |
var theClicker = $("#myClicker").clicker({ | |
isUpdated: function (event, data) { | |
console.log("isOneHundredOne"); | |
alert("Is " + data.myValue); | |
} | |
}); | |
theClicker.clicker({ newValue: 101 }); | |
</script> |
setting [newValue]: 101 | |
update:101 | |
calling isUpdated | |
isOneHundredOne | |
isUpdated has been called |
(function ($) { | |
$.widget("custom.clicker", { | |
// Default options. | |
options: { | |
newValue: 0 | |
}, | |
_create: function () { | |
this.element.text("The starting value is " + this.options.newValue); | |
}, | |
_setOption: function (key, value) { | |
console.log("setting [" + key + "]: " + value); | |
this.options[key] = value; | |
this._update(); | |
}, | |
_update: function () { | |
console.log("update:" + this.options.newValue); | |
this.element.text("The updated value is " + this.options.newValue); | |
if (this.options.newValue == 101) { | |
console.log("calling isUpdated"); | |
this._trigger("isUpdated", null, { myValue: this.options.newValue }); | |
console.log("isUpdated has been called"); | |
} | |
} | |
}); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment