Skip to content

Commit 24b7ff1

Browse files
committed
Widget demo: Don't use .toggle(fn).
1 parent fb91d90 commit 24b7ff1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

demos/widget/default.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,14 @@
139139
});
140140

141141
// click to toggle enabled/disabled
142-
$( "#disable" ).toggle(function() {
142+
$( "#disable" ).click(function() {
143143
// use the custom selector created for each widget to find all instances
144-
$( ":custom-colorize" ).colorize( "disable" );
145-
}, function() {
146-
$( ":custom-colorize" ).colorize( "enable" );
144+
// all instances are toggled together, so we can check the state from the first
145+
if ( $( ":custom-colorize" ).colorize( "option", "disabled" ) ) {
146+
$( ":custom-colorize" ).colorize( "enable" );
147+
} else {
148+
$( ":custom-colorize" ).colorize( "disable" );
149+
}
147150
});
148151

149152
// click to set options after initalization

0 commit comments

Comments
 (0)