diff --git a/select2.js b/select2.js index 2f9dd60d..80ce407b 100755 --- a/select2.js +++ b/select2.js @@ -380,6 +380,8 @@ /** * blurs any Select2 container that has focus when an element outside them was clicked or received focus + * + * also takes care of clicks on label tags that point to the source element */ $(document).ready(function () { $(document).delegate("*", "mousedown touchend", function (e) { @@ -394,6 +396,13 @@ if (this !== target) $(this).data("select2").blur(); }); } + + target=$(e.target); + if ("LABEL" === e.target.tagName && target.attr("for").length > 0) { + target = $("#"+target.attr("for")); + target = target.data("select2"); + if (target !== undefined) { target.focus(); e.preventDefault();} + } }); });