Created
April 2, 2014 14:03
-
-
Save bendytree/9934794 to your computer and use it in GitHub Desktop.
A patch for bootstrap-select v1.5.4 to fix the setStyle function. Currently setStyle doesn't properly keep track of what style was set previously, so the old style is never removed.
This file contains hidden or 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(){ | |
| //create a select so we can access the selectpicker | |
| var $div = $("<div><select></select></div>"); | |
| //get the prototype | |
| var prototype = $div.find("select").selectpicker().data("selectpicker").constructor.prototype; | |
| //keep track of the original setStyle | |
| var setStyle = prototype.setStyle; | |
| prototype.setStyle = function(style, status) { | |
| //call original setStyle | |
| setStyle.apply(this, arguments); | |
| //THE ONLY CHANGE - SAVE STYLE SO IT CAN BE REMOVED NEXT TIME | |
| if (style) { | |
| this.options.style = style; | |
| } | |
| }; | |
| //get rid of our temporary div | |
| $div.remove(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment