Forked from bkosborne/gist:56ee6a6559ac66d64490
Last active
September 10, 2015 10:32
-
-
Save thiago-negri/132bf33b5312e2da823c 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
(function() { | |
// see https://github.com/brianreavis/selectize.js/issues/470 | |
// extended from https://gist.github.com/bkosborne/56ee6a6559ac66d64490 | |
// gist at https://gist.github.com/thiago-negri/132bf33b5312e2da823c | |
Selectize | |
.define('no_results', function(options) { | |
var self = this; | |
options = $ | |
.extend({message: 'No results found.', html: function(data) { | |
return ('<div class="selectize-dropdown ' + data.classNames + ' dropdown-empty-message">' + '<div class="selectize-dropdown-content" style="padding: 3px 12px">' + data.message + '</div>' + '</div>'); | |
}}, options); | |
self.displayEmptyResultsMessage = function() { | |
this.$empty_results_container.css('top', this.$control.outerHeight()); | |
this.$empty_results_container.show(); | |
}; | |
self.on('type', function(str) { | |
if (self.loadedSearches[str] && !self.hasOptions) { | |
self.displayEmptyResultsMessage(); | |
} else { | |
self.$empty_results_container.hide(); | |
} | |
}); | |
self.onKeyDown = (function() { | |
var original = self.onKeyDown; | |
return function(e) { | |
original.apply(self, arguments); | |
this.$empty_results_container.hide(); | |
} | |
})(); | |
self.onBlur = (function() { | |
var original = self.onBlur; | |
return function() { | |
original.apply(self, arguments); | |
this.$empty_results_container.hide(); | |
}; | |
})(); | |
self.setup = (function() { | |
var original = self.setup; | |
return function() { | |
original.apply(self, arguments); | |
self.$empty_results_container = $(options.html($.extend({classNames: self.$input.attr('class')}, options))); | |
self.$empty_results_container.insertBefore(self.$dropdown); | |
self.$empty_results_container.hide(); | |
}; | |
})(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/thiago-negri/132bf33b5312e2da823c#file-selectize_no_results-js-L16
this.$empty_results_container.css('width', this.$control.outerWidth());