1
0
mirror of synced 2024-12-01 17:16:02 +03:00

fix hiding of search when minimumResultsForSearch are used. fixes #138

This commit is contained in:
Igor Vaynberg 2012-06-18 23:34:54 -07:00
parent b7c952a1a3
commit 8b566bf6ce

View File

@ -1162,11 +1162,13 @@
// hide the search box if this is the first we got the results and there are a few of them // hide the search box if this is the first we got the results and there are a few of them
if (initial === true) { if (initial === true) {
// TODO below we use data.results.length, but what we really need is something recursive to calc the length
// TODO in case there are optgroups
showSearchInput = this.showSearchInput = data.results.length >= this.opts.minimumResultsForSearch; showSearchInput = this.showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
this.container.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden"); this.dropdown.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden");
//add "select2-with-searchbox" to the container if search box is shown //add "select2-with-searchbox" to the container if search box is shown
this.container[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox"); $(this.dropdown, this.container)[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox");
} }
}, },