]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: disable / enable issue when reinit (refresh) selectmenu
authorFelix Nagel <info@felixnagel.com>
Tue, 31 May 2011 19:18:19 +0000 (21:18 +0200)
committerFelix Nagel <info@felixnagel.com>
Tue, 31 May 2011 19:18:19 +0000 (21:18 +0200)
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

ui/jquery.ui.selectmenu.js

index 4799bfc91cce13cca71043c199f3d2e5644298bf..3447bc08d8acf47bd8af230427b5ea9610791d40 100644 (file)
@@ -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());