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

Merge pull request #54 from Scavenger3/38de4c2c3b3c0e9a4da74e4ef3f47b7408e45b1a

skipOnChange doesn't skip
Mattia Larentis 12 éve
szülő
commit
84249ec8ff
1 módosított fájl, 4 hozzáadás és 1 törlés
  1. 4 1
      static/js/bootstrapSwitch.js

+ 4 - 1
static/js/bootstrapSwitch.js

@@ -107,7 +107,7 @@
               changeStatus($(this));
               changeStatus($(this));
             });
             });
 
 
-            $element.find('input').on('change', function (e) {
+            $element.find('input').on('change', function (e, skipOnChange) {
               var $this = $(this)
               var $this = $(this)
                 , $element = $this.parent()
                 , $element = $this.parent()
                 , thisState = $this.is(':checked')
                 , thisState = $this.is(':checked')
@@ -126,6 +126,9 @@
                 if ($element.data('animated') !== false)
                 if ($element.data('animated') !== false)
                   $element.addClass("switch-animate");
                   $element.addClass("switch-animate");
 
 
+                if (typeof skipOnChange === 'boolean' && skipOnChange)
+                  return;
+
                 $element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
                 $element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
               }
               }
             });
             });