Bläddra i källkod

label for support for id's with brackets, eg id='name[first]'. fixes #422

Igor Vaynberg 12 år sedan
förälder
incheckning
f7e78f6ed9
1 ändrade filer med 1 tillägg och 0 borttagningar
  1. 1 0
      select2.js

+ 1 - 0
select2.js

@@ -517,6 +517,7 @@
             target=$(e.target);
             attr = target.attr("for");
             if ("LABEL" === e.target.tagName && attr && attr.length > 0) {
+                attr = attr.replace(/([\[\].])/g,'\\$1'); /* escapes [, ], and . so properly selects the id */
                 target = $("#"+attr);
                 target = target.data("select2");
                 if (target !== undefined) { target.focus(); e.preventDefault();}