|
|
@@ -313,14 +313,10 @@
|
|
|
|
|
|
// 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.bv');
|
|
|
+ // 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);
|
|
|
} else {
|
|
|
- this.disableSubmitButtons(true);
|
|
|
-
|
|
|
- // Submit form
|
|
|
- this.$form.off('submit.bv').submit();
|
|
|
+ this.disableSubmitButtons(true).defaultSubmit();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -358,8 +354,8 @@
|
|
|
total = fields.length,
|
|
|
updateAll = (total == 1) || ('radio' == type) || ('checkbox' == type),
|
|
|
trigger = that.options.fields[field].trigger
|
|
|
- || that.options.trigger
|
|
|
- || (('radio' == type || 'checkbox' == type || 'file' == type || 'SELECT' == fields[0].tagName) ? 'change' : that._changeEvent),
|
|
|
+ || that.options.trigger
|
|
|
+ || (('radio' == type || 'checkbox' == type || 'file' == type || 'SELECT' == fields[0].tagName) ? 'change' : that._changeEvent),
|
|
|
events = $.map(trigger.split(' '), function(item) {
|
|
|
return item + '.live.bv';
|
|
|
}).join(' ');
|
|
|
@@ -391,6 +387,7 @@
|
|
|
// Don't disable if the live validating mode is disabled
|
|
|
this.$form.find(this.options.submitButtons).attr('disabled', 'disabled');
|
|
|
}
|
|
|
+
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
@@ -409,7 +406,11 @@
|
|
|
this.validateField(field);
|
|
|
}
|
|
|
|
|
|
- this._submit();
|
|
|
+ // Check if whether the submit button is clicked
|
|
|
+ if (this.$submitButton) {
|
|
|
+ this._submit();
|
|
|
+ }
|
|
|
+
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
@@ -475,7 +476,7 @@
|
|
|
updateAll ? that.updateStatus($f.attr('data-bv-field'), isValid ? that.STATUS_VALID : that.STATUS_INVALID, v)
|
|
|
: that.updateElementStatus($f, isValid ? that.STATUS_VALID : that.STATUS_INVALID, v);
|
|
|
|
|
|
- if (isValid && 'disabled' == that.options.live) {
|
|
|
+ if (isValid && 'disabled' == that.options.live && that.$submitButton) {
|
|
|
that._submit();
|
|
|
}
|
|
|
});
|
|
|
@@ -634,6 +635,16 @@
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * Submit the form using default submission.
|
|
|
+ * It also does not perform any validations when submitting the form
|
|
|
+ *
|
|
|
+ * It might be used when you want to submit the form right inside the submitHandler()
|
|
|
+ */
|
|
|
+ defaultSubmit: function() {
|
|
|
+ this.$form.off('submit.bv').submit();
|
|
|
+ },
|
|
|
+
|
|
|
// Useful APIs which aren't used internally
|
|
|
|
|
|
/**
|