瀏覽代碼

Merge pull request #346 from Polonious/master

Escapes special characters in containerId selector
Igor Vaynberg 12 年之前
父節點
當前提交
b5cceab21e
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      select2.js

+ 2 - 1
select2.js

@@ -560,6 +560,7 @@
             this.container = this.createContainer();
             this.container = this.createContainer();
 
 
             this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
             this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
+            this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
             this.container.attr("id", this.containerId);
             this.container.attr("id", this.containerId);
 
 
             // cache the body so future lookups are cheap
             // cache the body so future lookups are cheap
@@ -942,7 +943,7 @@
          */
          */
         // abstract
         // abstract
         opening: function() {
         opening: function() {
-            var cid = this.containerId, selector = "#"+ cid,
+            var cid = this.containerId, selector = this.containerSelector,
                 scroll = "scroll." + cid, resize = "resize." + cid;
                 scroll = "scroll." + cid, resize = "resize." + cid;
 
 
             this.container.parents().each(function() {
             this.container.parents().each(function() {