Created
May 5, 2014 15:35
-
-
Save lananelson/3247f07e1d663b4aeb69 to your computer and use it in GitHub Desktop.
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
Selectize.define('fix_drodown_in_ie', function(options) { | |
var self = this; | |
self.setup = (function() { | |
var original = self.setup; | |
return function() { | |
original.apply(this, arguments); | |
self.$control_input.on({ | |
focus: function() { | |
self.ignoreBlur = false; return self.onFocus.apply(self, arguments); | |
} | |
}); | |
}; | |
})(); | |
self.onBlur = (function(e) { | |
return function(e) { | |
var self = this; | |
self.isFocused = false; | |
// necessary to prevent IE closing the dropdown when the scrollbar is clicked | |
if (self.ignoreFocus) return; | |
if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) { | |
self.ignoreBlur = true; | |
self.onFocus(e); | |
return; | |
} | |
if (self.settings.create && self.settings.createOnBlur) { | |
self.createItem(); | |
} | |
self.close(); | |
self.setTextboxValue(''); | |
self.setActiveItem(null); | |
self.setActiveOption(null); | |
self.setCaret(self.items.length); | |
self.refreshState(); | |
}; | |
})(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment