1
0
mirror of synced 2024-11-26 06:46:04 +03:00

added focus() and isFocused(). closes #39

This commit is contained in:
Igor Vaynberg 2012-04-20 23:59:44 -07:00
parent a542280595
commit 6ec4d20d02

View File

@ -821,6 +821,15 @@
this.parent.close.apply(this, arguments); this.parent.close.apply(this, arguments);
}, },
focus: function () {
this.close();
this.selection.focus();
},
isFocused: function () {
return this.selection.is(":focus");
},
cancel: function () { cancel: function () {
this.parent.cancel.apply(this, arguments); this.parent.cancel.apply(this, arguments);
this.selection.focus(); this.selection.focus();
@ -1188,6 +1197,15 @@
this.parent.close.apply(this, arguments); this.parent.close.apply(this, arguments);
}, },
focus: function () {
this.close();
this.search.focus();
},
isFocused: function () {
return this.search.is(":focus");
},
updateSelection: function (data) { updateSelection: function (data) {
var ids = [], filtered = [], self = this; var ids = [], filtered = [], self = this;
@ -1383,7 +1401,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"]; value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused"];
this.each(function () { this.each(function () {
if (args.length === 0 || typeof(args[0]) === "object") { if (args.length === 0 || typeof(args[0]) === "object") {