소스 검색

Improve distory function and some documents

Aimeast 12 년 전
부모
커밋
2f1e05dfb4
2개의 변경된 파일16개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 1
      examples/index.html
  2. 8 1
      static/js/bootstrap-switch.js

+ 8 - 1
examples/index.html

@@ -314,7 +314,7 @@ $('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</pre
 
 <div class="row-fluid">
     <div class="span12">
-        <h3>Form <small>- try to use tab and space</small></h3>
+        <h3>Form <small>- try to use tab, space and reset button</small></h3>
 
         <div class="bs-docs-example">
             <form class="form-horizontal span8 offset2">
@@ -343,6 +343,10 @@ $('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</pre
                         </div>
                     </div>
                 </div>
+
+                <div class="form-actions">
+                    <button type="reset" class="btn btn-inverse">Reset</button>
+                </div>
             </form>
             <div class="clearfix"></div>
         </div>
@@ -370,6 +374,9 @@ $('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</pre
             &lt;/div>
         &lt;/div>
     &lt;/div>
+    &lt;div class="form-actions">
+        &lt;button type="reset" class="btn btn-inverse">Reset&lt;/button>
+    &lt;/div>
 &lt;/form></pre>
     </div>
 </div>

+ 8 - 1
static/js/bootstrap-switch.js

@@ -249,7 +249,9 @@
         return $(this).find('input:checkbox').is(':checked');
       },
       destroy: function () {
-        var $div = $(this).find('div')
+        var $element = $(this)
+          , $div = $element.find('div')
+          , $form = $element.closest('form')
           , $checkbox;
 
         $div.find(':not(input:checkbox)').remove();
@@ -259,6 +261,11 @@
 
         $checkbox.unbind('change');
 
+        if ($form) {
+          $form.unbind('reset');
+          $form.removeData('bootstrapSwitch');
+        }
+
         return $checkbox;
       }
     };