Selectmenu: Fixed event unbinding.

This commit is contained in:
Scott González 2012-07-17 15:27:26 -04:00
parent 06372cdcc8
commit 549b97ed6c

View File

@ -108,7 +108,8 @@ $.widget( "ui.selectmenu", {
}, },
_drawMenu: function() { _drawMenu: function() {
var that = this; var menuInstance,
that = this;
// create menu portion, append to body // create menu portion, append to body
this.menu = $( '<ul />', { this.menu = $( '<ul />', {
@ -126,7 +127,7 @@ $.widget( "ui.selectmenu", {
.appendTo( this.options.appendTo ); .appendTo( this.options.appendTo );
// init menu widget // init menu widget
this.menu.menu({ menuInstance = this.menu.menu({
select: function( event, ui ) { select: function( event, ui ) {
var item = ui.item.data( "item.selectmenu" ); var item = ui.item.data( "item.selectmenu" );
@ -152,7 +153,8 @@ $.widget( "ui.selectmenu", {
}, },
// set ARIA role // set ARIA role
role: 'listbox' role: 'listbox'
}); })
.data( "ui-menu" );
// change menu styles? // change menu styles?
if ( this.options.dropdown ) { if ( this.options.dropdown ) {
@ -160,8 +162,8 @@ $.widget( "ui.selectmenu", {
} }
// unbind uneeded Menu events // unbind uneeded Menu events
this.menu.off( "mouseleave.menu" ); menuInstance._off( this.menu, "mouseleave" );
$( document ).off( "click.menu" ); menuInstance._off( this.document, "click" );
}, },
refresh: function() { refresh: function() {
@ -294,7 +296,7 @@ $.widget( "ui.selectmenu", {
focus: function( event ) { focus: function( event ) {
// init Menu on first focus // init Menu on first focus
this.refresh(); this.refresh();
this.button.off( "focus." + this.widgetName ); this._off( this.button, "focus" );
}, },
click: function( event ) { click: function( event ) {
this._toggle( event ); this._toggle( event );