Last active
August 29, 2015 14:16
-
-
Save devdays/0c380c1e707a98a1638d to your computer and use it in GitHub Desktop.
Your widget responds to changes of an option
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
_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