Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed: disable enable demo

  • Loading branch information...
commit e68126e866cd9d63387795a601f74c06812b0f6b 1 parent d347aa5
Felix Nagel authored
Showing with 20 additions and 16 deletions.
  1. +4 −4 demos/selectmenu/disable_enable.html
  2. +16 −12 ui/jquery.ui.selectmenu.js
8 demos/selectmenu/disable_enable.html
View
@@ -58,10 +58,10 @@
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);
}
);
@@ -74,10 +74,10 @@
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");
}
);
28 ui/jquery.ui.selectmenu.js
View
@@ -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" );
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.