1
0
mirror of synced 2025-02-14 02:53:14 +03:00

Fixes >1 multi-select dropdown being open at the same time

Bug was reproduced on latest FF/Chrome/Safari, but IE exibits correct
behavior with or without the fix.

See: http://jsfiddle.net/tmD7c/2/
This commit is contained in:
tom 2012-12-10 12:46:27 -05:00
parent c135db876e
commit b33c86e5e4

View File

@ -509,16 +509,19 @@ the specific language governing permissions and limitations under the Apache Lic
$document.ready(function () { $document.ready(function () {
$document.bind("mousedown touchend", function (e) { $document.bind("mousedown touchend", function (e) {
var target = $(e.target).closest("div.select2-container").get(0), attr; var target = $(e.target).closest("div.select2-container").get(0), attr;
var targetDropdown = null;
if (target) { if (target) {
$document.find("div.select2-container-active").each(function () { $document.find("div.select2-container-active").each(function () {
if (this !== target) $(this).data("select2").blur(); if (this !== target) $(this).data("select2").blur();
}); });
} else { targetDropdown = $(target).data('select2').dropdown.get(0);
target = $(e.target).closest("div.select2-drop").get(0); }
// close any other active dropdowns
target = targetDropdown || $(e.target).closest("div.select2-drop").get(0);
$document.find("div.select2-drop-active").each(function () { $document.find("div.select2-drop-active").each(function () {
if (this !== target) $(this).data("select2").blur(); if (this !== target) $(this).data("select2").blur();
}); });
}
target=$(e.target); target=$(e.target);
attr = target.attr("for"); attr = target.attr("for");