Skip to content

Instantly share code, notes, and snippets.

@lananelson
Created May 5, 2014 15:35
Show Gist options
  • Save lananelson/3247f07e1d663b4aeb69 to your computer and use it in GitHub Desktop.
Save lananelson/3247f07e1d663b4aeb69 to your computer and use it in GitHub Desktop.
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