Skip to content

Commit 1633d71

Browse files
committed
add container() method that retrieves the main container
1 parent cb7f1da commit 1633d71

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

select2.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@
14241424
var args = Array.prototype.slice.call(arguments, 0),
14251425
opts,
14261426
select2,
1427-
value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused"];
1427+
value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused", "container"];
14281428

14291429
this.each(function () {
14301430
if (args.length === 0 || typeof(args[0]) === "object") {
@@ -1449,7 +1449,11 @@
14491449
value = undefined;
14501450
select2 = $(this).data("select2");
14511451
if (select2 === undefined) return;
1452-
value = select2[args[0]].apply(select2, args.slice(1));
1452+
if (args[0] === "container") {
1453+
value=select2.container;
1454+
} else {
1455+
value = select2[args[0]].apply(select2, args.slice(1));
1456+
}
14531457
if (value !== undefined) {return false;}
14541458
} else {
14551459
throw "Invalid arguments to select2 plugin: " + args;

0 commit comments

Comments
 (0)