Skip to content

Instantly share code, notes, and snippets.

@devdays
Last active August 29, 2015 14:16
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/0c380c1e707a98a1638d to your computer and use it in GitHub Desktop.
Save devdays/0c380c1e707a98a1638d to your computer and use it in GitHub Desktop.
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