Selectmenu: use method _documentClick for adding events to the document

This commit is contained in:
Felix Nagel 2012-12-12 17:26:17 +01:00
parent f6372bd7ea
commit 07328359e9

View File

@ -43,14 +43,7 @@ $.widget( "ui.selectmenu", {
this._drawButton(); this._drawButton();
this._drawMenu(); this._drawMenu();
// document click closes menu this._on( document, this._documentClick );
this._on( document, {
click: function( event ) {
if ( this.isOpen && !$( event.target ).closest( "li.ui-state-disabled, li.ui-selectmenu-optgroup, #" + this.ids.button ).length ) {
this.close( event );
}
}
});
if ( this.options.disabled ) { if ( this.options.disabled ) {
this.disable(); this.disable();
@ -304,6 +297,14 @@ $.widget( "ui.selectmenu", {
} }
}, },
_documentClick: {
click: function( event ) {
if ( this.isOpen && !$( event.target ).closest( "li.ui-state-disabled, li.ui-selectmenu-optgroup, #" + this.ids.button ).length ) {
this.close( event );
}
}
},
_buttonEvents: { _buttonEvents: {
focus: function() { focus: function() {
// init Menu on first focus // init Menu on first focus