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

index 03ae2ad7d245eb166f1238651c71d045225dc183..1827724b9639a7edd5118f18d91ad761f0faaba4 100644 (file)
        <script>
        $(function() {
                var spinner = $( "#spinner" ).spinner();
-               
-               $( "#disable" ).toggle(function() {
-                       spinner.spinner( "disable" );
-               }, function() {
-                       spinner.spinner( "enable" );
+
+               $( "#disable" ).click(function() {
+                       if ( spinner.spinner( "option", "disabled" ) ) {
+                               spinner.spinner( "enable" );
+                       } else {
+                               spinner.spinner( "disable" );
+                       }
                });
-               $( "#destroy" ).toggle(function() {
-                       spinner.spinner( "destroy" );
-               }, function() {
-                       spinner.spinner();
+               $( "#destroy" ).click(function() {
+                       if ( spinner.data( "ui-spinner" ) ) {
+                               spinner.spinner( "destroy" );
+                       } else {
+                               spinner.spinner();
+                       }
                });
                $( "#getvalue" ).click(function() {
                        alert( spinner.spinner( "value" ) );