浏览代码

#105: Cannot call form.submit() inside submitHandler

nghuuphuoc 11 年之前
父节点
当前提交
92fc9e1c80
共有 5 个文件被更改,包括 8 次插入3 次删除
  1. 2 1
      CHANGELOG.md
  2. 1 1
      demo/submitHandler.html
  3. 2 0
      dist/js/bootstrapValidator.js
  4. 1 1
      dist/js/bootstrapValidator.min.js
  5. 2 0
      src/js/bootstrapValidator.js

+ 2 - 1
CHANGELOG.md

@@ -6,7 +6,8 @@ Not released yet
 
 __Fixes__:
 
-[#77, #117: ```notEmpty``` validator doesn't work on file input](https://github.com/nghuuphuoc/bootstrapvalidator/issues/117)
+* [#77, #117: ```notEmpty``` validator doesn't work on file input](https://github.com/nghuuphuoc/bootstrapvalidator/issues/117)
+* [#105: Cannot call ```form.submit()``` inside ```submitHandler```](https://github.com/nghuuphuoc/bootstrapvalidator/issues/105)
 
 ## v0.3.2
 

+ 1 - 1
demo/submitHandler.html

@@ -20,7 +20,7 @@
                     <h2>Custom submit handler</h2>
                 </div>
 
-                <form id="defaultForm" method="post" class="form-horizontal">
+                <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
                     <div class="alert alert-success" style="display: none;"></div>
 
                     <div class="form-group">

+ 2 - 0
dist/js/bootstrapValidator.js

@@ -275,6 +275,8 @@
 
             // Call the custom submission if enabled
             if (this.options.submitHandler && 'function' == typeof this.options.submitHandler) {
+                // Turn off the submit handler, so user can call form.submit() inside their submitHandler method
+                this.$form.off('submit.bootstrapValidator');
                 this.options.submitHandler.call(this, this, this.$form, this.$submitButton);
             } else {
                 // Submit form

文件差异内容过多而无法显示
+ 1 - 1
dist/js/bootstrapValidator.min.js


+ 2 - 0
src/js/bootstrapValidator.js

@@ -274,6 +274,8 @@
 
             // Call the custom submission if enabled
             if (this.options.submitHandler && 'function' == typeof this.options.submitHandler) {
+                // Turn off the submit handler, so user can call form.submit() inside their submitHandler method
+                this.$form.off('submit.bootstrapValidator');
                 this.options.submitHandler.call(this, this, this.$form, this.$submitButton);
             } else {
                 // Submit form