浏览代码

#42: Add new ```getSubmitButton()``` method to get the clicked submit button

nghuuphuoc 11 年之前
父节点
当前提交
de5e341b7a
共有 4 个文件被更改,包括 40 次插入13 次删除
  1. 17 6
      CHANGELOG.md
  2. 11 3
      dist/js/bootstrapValidator.js
  3. 1 1
      dist/js/bootstrapValidator.min.js
  4. 11 3
      src/js/bootstrapValidator.js

文件差异内容过多而无法显示
+ 17 - 6
CHANGELOG.md


+ 11 - 3
dist/js/bootstrapValidator.js

@@ -123,10 +123,9 @@
         // The custom submit handler
         // It will prevent the form from the default submission
         //
-        //  submitHandler: function(validator, form, submitButton) {
+        //  submitHandler: function(validator, form) {
         //      - validator is the BootstrapValidator instance
         //      - form is the jQuery object presenting the current form
-        //      - submitButton is the jQuery object presenting the clicked button
         //  }
         submitHandler: null,
 
@@ -549,7 +548,7 @@
             // Call the custom submission if enabled
             if (this.options.submitHandler && 'function' == typeof this.options.submitHandler) {
                 // If you want to submit the form inside your submit handler, please call defaultSubmit() method
-                this.options.submitHandler.call(this, this, this.$form, this.$submitButton);
+                this.options.submitHandler.call(this, this, this.$form);
             } else {
                 this.disableSubmitButtons(true).defaultSubmit();
             }
@@ -1016,6 +1015,15 @@
         },
 
         /**
+         * Returns the clicked submit button
+         *
+         * @returns {jQuery}
+         */
+        getSubmitButton: function() {
+            return this.$submitButton;
+        },
+
+        /**
          * Get the error messages
          *
          * @param {String|jQuery} [field] The field name or field element

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


+ 11 - 3
src/js/bootstrapValidator.js

@@ -122,10 +122,9 @@
         // The custom submit handler
         // It will prevent the form from the default submission
         //
-        //  submitHandler: function(validator, form, submitButton) {
+        //  submitHandler: function(validator, form) {
         //      - validator is the BootstrapValidator instance
         //      - form is the jQuery object presenting the current form
-        //      - submitButton is the jQuery object presenting the clicked button
         //  }
         submitHandler: null,
 
@@ -548,7 +547,7 @@
             // Call the custom submission if enabled
             if (this.options.submitHandler && 'function' == typeof this.options.submitHandler) {
                 // If you want to submit the form inside your submit handler, please call defaultSubmit() method
-                this.options.submitHandler.call(this, this, this.$form, this.$submitButton);
+                this.options.submitHandler.call(this, this, this.$form);
             } else {
                 this.disableSubmitButtons(true).defaultSubmit();
             }
@@ -1015,6 +1014,15 @@
         },
 
         /**
+         * Returns the clicked submit button
+         *
+         * @returns {jQuery}
+         */
+        getSubmitButton: function() {
+            return this.$submitButton;
+        },
+
+        /**
          * Get the error messages
          *
          * @param {String|jQuery} [field] The field name or field element