浏览代码

add container() method that retrieves the main container

Igor Vaynberg 13 年之前
父节点
当前提交
1633d71b4a
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      select2.js

+ 6 - 2
select2.js

@@ -1424,7 +1424,7 @@
         var args = Array.prototype.slice.call(arguments, 0),
         var args = Array.prototype.slice.call(arguments, 0),
             opts,
             opts,
             select2,
             select2,
-            value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused"];
+            value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused", "container"];
 
 
         this.each(function () {
         this.each(function () {
             if (args.length === 0 || typeof(args[0]) === "object") {
             if (args.length === 0 || typeof(args[0]) === "object") {
@@ -1449,7 +1449,11 @@
                 value = undefined;
                 value = undefined;
                 select2 = $(this).data("select2");
                 select2 = $(this).data("select2");
                 if (select2 === undefined) return;
                 if (select2 === undefined) return;
-                value = select2[args[0]].apply(select2, args.slice(1));
+                if (args[0] === "container") {
+                    value=select2.container;
+                } else {
+                    value = select2[args[0]].apply(select2, args.slice(1));
+                }
                 if (value !== undefined) {return false;}
                 if (value !== undefined) {return false;}
             } else {
             } else {
                 throw "Invalid arguments to select2 plugin: " + args;
                 throw "Invalid arguments to select2 plugin: " + args;