added focus() and isFocused(). closes #39
This commit is contained in:
parent
a542280595
commit
6ec4d20d02
20
select2.js
20
select2.js
@ -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") {
|
||||||
|
Loading…
Reference in New Issue
Block a user