Forráskód Böngészése

Listing 3.22: selecting handler unbiding.

Frederic G. MARAND 8 éve
szülő
commit
0651b2b3ff
1 módosított fájl, 8 hozzáadás és 6 törlés
  1. 8 6
      Chapter 3/03.js

+ 8 - 6
Chapter 3/03.js

@@ -17,13 +17,15 @@ $(document).ready(function () {
     }
   };
 
-  $('#switcher').on('click.collapse', toggleSwitcher);
+  $('#switcher').on('click', toggleSwitcher);
+
+  $('#switcher button').click(function () {
+    $('#switcher').off('click', toggleSwitcher);
+
+    if (this.id == 'switcher-default') {
+      $('#switcher').on('click', toggleSwitcher);
+    }
 
-  $('#switcher-narrow, #switcher-large').click(function () {
-    $('#switcher').off('click.collapse');
-  });
-  $('#switcher-default').click(function () {
-    $('#switcher').on('click.collapse', toggleSwitcher);
   });
 });