From: Felix Nagel Date: Tue, 31 May 2011 19:18:19 +0000 (+0200) Subject: fixed: disable / enable issue when reinit (refresh) selectmenu X-Git-Tag: selectmenu_v1.1.0~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d5958c1b437a3324b5352f8617bfa0735499ba1b;p=jquery-ui.git fixed: disable / enable issue when reinit (refresh) selectmenu fixed: mousedown/mouseup listener was bind multiple times when widget was reinitialized both thx to czindel, see https://github.com/fnagel/jquery-ui/pull/125 --- diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 4799bfc91..3447bc08d 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -231,7 +231,10 @@ $.widget("ui.selectmenu", { .bind('keypress.selectmenu', function(event) { self._typeAhead(event.which, 'focus'); return true; - }); + }) + // this allows for using the scrollbar in an overflowed list + .bind( 'mousedown.selectmenu mouseup.selectmenu', function() { return false; }); + // needed when window is resized $(window).bind( "resize.selectmenu", $.proxy( self._refreshPosition, this ) ); @@ -314,9 +317,6 @@ $.widget("ui.selectmenu", { thisLi.appendTo(this.list); } - // this allows for using the scrollbar in an overflowed list - this.list.bind('mousedown.selectmenu mouseup.selectmenu', function() { return false; }); - // append icon if option is specified if (o.icons) { for (var j in o.icons) { @@ -383,10 +383,12 @@ $.widget("ui.selectmenu", { this._optionLis = this.list.find('li:not(.' + self.widgetBaseClass + '-group)'); // transfer disabled state - if (this.element.attr('disabled') === true) { + if ( this.element.attr( 'disabled' ) === true ) { this.disable(); + } else { + this.enable() } - + // update value this.index(this._selectedIndex());