From 34913e95573086aeba1952c31b6b28cb3cb82570 Mon Sep 17 00:00:00 2001 From: Grzegorz Kaczan Date: Mon, 16 Apr 2012 15:23:14 +0200 Subject: [PATCH] Add "select2-with-searchbox" to the dropdown container if search box is shown. Signed-off-by: Igor Vaynberg --- select2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index df7ddf88..46b75473 100755 --- a/select2.js +++ b/select2.js @@ -948,7 +948,7 @@ }, postprocessResults: function (data, initial) { - var selected = 0, self = this; + var selected = 0, self = this, toggleSearchInput = true;; // find the selected element in the result list @@ -966,7 +966,11 @@ // hide the search box if this is the first we got the results and there are a few of them if (initial === true) { - this.search.parent().toggle(data.results.length >= this.opts.minimumResultsForSearch); + toggleSearchInput = data.results.length >= this.opts.minimumResultsForSearch; + this.search.parent().toggle(toggleSearchInput); + + //add "select2-with-searchbox" to the dropdown container if search box is shown + this.container[toggleSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox"); } },