Jelajahi Sumber

switch state as init event second parameter

Emanuele Marchi 10 tahun lalu
induk
melakukan
c23201900e

+ 1 - 1
dist/js/bootstrap-switch.js

@@ -115,7 +115,7 @@
         this._labelHandlers();
         this._labelHandlers();
         this._formHandler();
         this._formHandler();
         this._externalLabelHandler();
         this._externalLabelHandler();
-        this.$element.trigger("init.bootstrapSwitch");
+        this.$element.trigger("init.bootstrapSwitch", this.options.state);
       }
       }
 
 
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;

File diff ditekan karena terlalu besar
+ 0 - 0
dist/js/bootstrap-switch.min.js


+ 4 - 1
events.html

@@ -79,7 +79,10 @@
             <tr>
             <tr>
               <td>init</td>
               <td>init</td>
               <td>Triggered on initialization. 'this' refers to the DOM element.</td>
               <td>Triggered on initialization. 'this' refers to the DOM element.</td>
-              <td>event (<a href="https://api.jquery.com/category/events/event-object/" target="_blank">jQuery Event object</a>)</td>
+              <td>
+                event (<a href="https://api.jquery.com/category/events/event-object/" target="_blank">jQuery Event object</a>)
+                state (true | false)
+              </td>
             </tr>
             </tr>
             <tr>
             <tr>
               <td>switchChange</td>
               <td>switchChange</td>

+ 1 - 1
src/coffee/bootstrap-switch.coffee

@@ -74,7 +74,7 @@ do ($ = window.jQuery, window) ->
       @_formHandler()
       @_formHandler()
       @_externalLabelHandler()
       @_externalLabelHandler()
 
 
-      @$element.trigger "init.bootstrapSwitch"
+      @$element.trigger "init.bootstrapSwitch", @options.state
 
 
     _constructor: BootstrapSwitch
     _constructor: BootstrapSwitch
 
 

+ 1 - 0
src/docs/jade/events.jade

@@ -30,6 +30,7 @@ block content
           td Triggered on initialization. 'this' refers to the DOM element.
           td Triggered on initialization. 'this' refers to the DOM element.
           td
           td
             | event (<a href="https://api.jquery.com/category/events/event-object/" target="_blank">jQuery Event object</a>)
             | event (<a href="https://api.jquery.com/category/events/event-object/" target="_blank">jQuery Event object</a>)
+            | state (true | false)
         tr
         tr
           td switchChange
           td switchChange
           td Triggered on switch state change. 'this' refers to the DOM element.
           td Triggered on switch state change. 'this' refers to the DOM element.

+ 1 - 1
test/bootstrap-switch.js

@@ -115,7 +115,7 @@
         this._labelHandlers();
         this._labelHandlers();
         this._formHandler();
         this._formHandler();
         this._externalLabelHandler();
         this._externalLabelHandler();
-        this.$element.trigger("init.bootstrapSwitch");
+        this.$element.trigger("init.bootstrapSwitch", this.options.state);
       }
       }
 
 
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini