]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget demo: Don't use .toggle(fn).
authorScott González <scott.gonzalez@gmail.com>
Mon, 21 May 2012 14:11:01 +0000 (10:11 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 21 May 2012 14:11:01 +0000 (10:11 -0400)
demos/widget/default.html

index ece81218a75dfd97d89599fc20f44671e3c131e9..f39825034a25e4f16408bf802696961f7ea2c8c2 100644 (file)
                });
 
                // click to toggle enabled/disabled
-               $( "#disable" ).toggle(function() {
+               $( "#disable" ).click(function() {
                        // use the custom selector created for each widget to find all instances
-                       $( ":custom-colorize" ).colorize( "disable" );
-               }, function() {
-                       $( ":custom-colorize" ).colorize( "enable" );
+                       // all instances are toggled together, so we can check the state from the first
+                       if ( $( ":custom-colorize" ).colorize( "option", "disabled" ) ) {
+                               $( ":custom-colorize" ).colorize( "enable" );
+                       } else {
+                               $( ":custom-colorize" ).colorize( "disable" );
+                       }
                });
 
                // click to set options after initalization