From b3089218dcb9dbc1de226408e74bcf43eac690d8 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Wed, 25 Jul 2012 00:55:53 +0300 Subject: [PATCH] fix tracking of results under mouse. fixes #258 --- select2.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/select2.js b/select2.js index 2cb95ff5..651d0b14 100755 --- a/select2.js +++ b/select2.js @@ -1891,20 +1891,29 @@ postprocessResults: function () { var val = this.getVal(), choices = this.results.find(".select2-result-selectable"), + compound = this.results.find(".select2-result-with-children"), self = this; choices.each2(function (i, choice) { var id = self.id(choice.data("select2-data")); if (indexOf(id, val) >= 0) { - choice.addClass("select2-disabled"); + choice.addClass("select2-disabled").removeClass("select2-result-selectable"); } else { - choice.removeClass("select2-disabled"); + choice.removeClass("select2-disabled").addClass("select2-result-selectable"); + } + }); + + compound.each2(function(i, e) { + if (e.find(".select2-result-selectable").length==0) { + e.addClass("select2-disabled"); + } else { + e.removeClass("select2-disabled"); } }); choices.each2(function (i, choice) { - if (!choice.hasClass("select2-disabled")) { - self.highlight(i); + if (!choice.hasClass("select2-disabled") && choice.hasClass("select2-result-selectable")) { + self.highlight(0); return false; } });