Skip to content

Instantly share code, notes, and snippets.

@devdays
Last active Aug 29, 2015
Embed
What would you like to do?
Your widget responds to changes of an option
_setOption: function (key, value) {
var oldValue = this.options[key];
// Check for a particular option being set
if (key === "className") {
// Gather all the elements we applied the className to
this.filterInput.parent().add(this.filterElems)
// Switch the new className in for the old
.toggleClass(oldValue + " " + value);
}
// Call the base _setOption method
this._super(key, value);
// The widget factory doesn't fire an callback for options changes by default
// In order to allow the user to respond, fire our own callback
this._trigger("setOption", null, {
option: key,
original: oldValue,
current: value
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment