From eddc9ea49a3fbfbcfe87922ea8cb12f229c82ca8 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Sun, 24 Jul 2016 12:26:05 -0600 Subject: [PATCH] Moving the beforeSubmit event above where the options are appended to the URL so you can change the options before submit. --- jquery.form.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..329128d5 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -145,6 +145,12 @@ $.fn.ajaxSubmit = function(options) { traditional = $.ajaxSettings.traditional; } + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + var elements = []; var qx, a = this.formToArray(options.semantic, elements); if (options.data) { @@ -152,11 +158,7 @@ $.fn.ajaxSubmit = function(options) { qx = $.param(options.data, traditional); } - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } + // fire vetoable 'validate' event this.trigger('form-submit-validate', [a, this, options, veto]);