]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: disable enable demo
authorFelix Nagel <info@felixnagel.com>
Fri, 23 Nov 2012 22:10:41 +0000 (23:10 +0100)
committerFelix Nagel <info@felixnagel.com>
Fri, 23 Nov 2012 22:29:35 +0000 (23:29 +0100)
demos/selectmenu/disable_enable.html
ui/jquery.ui.selectmenu.js

index 1191150bafd5489e5530dad604b3ec788f415709..020296c35f155c3df3b49a8556e7846428fdcf2a 100644 (file)
                        var speedB2 = $('select#speedB2').selectmenu();                 
                        $("#optionSwitch").toggle(
                                function(){
-                                       speedB2.selectmenu("disable", 2);
+                                       speedB2.selectmenu("enable", 2);
                                }, 
                                function(){
-                                       speedB2.selectmenu("enable", 2);
+                                       speedB2.selectmenu("disable", 2);
                                }
                        );                      
                        
                        var speedD2 = $('select#speedD2').selectmenu();                         
                        $("#optgroupSwitch").toggle(
                                function(){
-                                       speedD2.selectmenu("disable", 1, "optgroup");
+                                       speedD2.selectmenu("enable", 1, "optgroup");
                                }, 
                                function(){
-                                       speedD2.selectmenu("enable", 1, "optgroup");
+                                       speedD2.selectmenu("disable", 1, "optgroup");
                                }
                        );                      
 
index 0418327442433014c9c516fbccda4d155f036284..65eadc5ec7c3a104d0eeb2b2200266a8e43d01be 100644 (file)
@@ -721,7 +721,7 @@ $.widget("ui.selectmenu", {
                                this._setOption( 'disabled', true );
                        } else {
                                if ( type == "optgroup" ) {
-                                       this._toggleOptgroup( index, false );
+                                       this._disableOptgroup( index );
                                } else {
                                        this._disableOption( index );
                                }
@@ -734,7 +734,7 @@ $.widget("ui.selectmenu", {
                                this._setOption( 'disabled', false );
                        } else {
                                if ( type == "optgroup" ) {
-                                       this._toggleOptgroup( index, true );
+                                       this._enableOptgroup( index );
                                } else {
                                        this._enableOption( index );
                                }
@@ -764,18 +764,22 @@ $.widget("ui.selectmenu", {
                        }
        },
 
-       // true = enabled, false = disabled
-       _toggleOptgroup: function( index, flag ) {
+       _disableOptgroup: function( index ) {
                        var optGroupElem = this.list.find( 'li.ui-selectmenu-group-' + index );
-                       if ( optGroupElem ) {                           
+                       if ( optGroupElem ) {
                                optGroupElem
-                                       .toggleClass( this.namespace + '-state-disabled', flag )
-                                       .attr( "aria-disabled", !flag );
-                               if ( flag ) {
-                                       this.element.find( "optgroup" ).eq( index ).attr( "disabled", "disabled" );
-                               } else {
-                                       this.element.find( "optgroup" ).eq( index ).removeAttr( "disabled" );
-                               }
+                                       .addClass( this.namespace + '-state-disabled' )
+                                       .attr( "aria-disabled", true );
+                               this.element.find( "optgroup" ).eq( index ).attr( "disabled", "disabled" );
+                       }
+       },
+
+       _enableOptgroup: function( index ) {
+                       var optGroupElem = this.list.find( 'li.ui-selectmenu-group-' + index );
+                       if ( optGroupElem ) {
+                               optGroupElem.removeClass( this.namespace + '-state-disabled' )
+                                       .attr( "aria-disabled", false);
+                               this.element.find( "optgroup" ).eq( index ).removeAttr( "disabled" );
                        }
        },