added open event
This commit is contained in:
parent
f272ac9f80
commit
6a5719db80
35
select2.js
35
select2.js
@ -737,9 +737,27 @@
|
||||
this.dropdown.css(css);
|
||||
},
|
||||
|
||||
// abstract
|
||||
shouldOpen: function() {
|
||||
var event;
|
||||
|
||||
if (this.opened()) return false;
|
||||
|
||||
event = jQuery.Event("open");
|
||||
this.opts.element.trigger(event);
|
||||
return !event.isDefaultPrevented();
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens the dropdown
|
||||
*
|
||||
* @return {Boolean} whether or not dropdown was opened. This method will return false if, for example,
|
||||
* the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
|
||||
*/
|
||||
// abstract
|
||||
open: function () {
|
||||
if (this.opened()) return;
|
||||
|
||||
if (!this.shouldOpen()) return false;
|
||||
|
||||
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
||||
if(this.dropdown[0] !== this.body.children().last()[0]) {
|
||||
@ -755,6 +773,8 @@
|
||||
this.dropdown.show();
|
||||
this.ensureHighlightVisible();
|
||||
this.focusSearch();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
// abstract
|
||||
@ -1060,15 +1080,6 @@
|
||||
"</div>"].join(""));
|
||||
},
|
||||
|
||||
// single
|
||||
open: function () {
|
||||
|
||||
if (this.opened()) return;
|
||||
|
||||
this.parent.open.apply(this, arguments);
|
||||
|
||||
},
|
||||
|
||||
// single
|
||||
close: function () {
|
||||
if (!this.opened()) return;
|
||||
@ -1544,11 +1555,11 @@
|
||||
|
||||
// multi
|
||||
open: function () {
|
||||
if (this.opened()) return;
|
||||
this.parent.open.apply(this, arguments);
|
||||
if (this.parent.open.apply(this, arguments) === false) return false;
|
||||
this.clearPlaceholder();
|
||||
this.resizeSearch();
|
||||
this.focusSearch();
|
||||
return true;
|
||||
},
|
||||
|
||||
// multi
|
||||
|
Loading…
x
Reference in New Issue
Block a user