diff --git a/jquery.form.js b/jquery.form.js index b216c900..f82c1940 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -165,6 +165,12 @@ $.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { 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, options.filtering); if (options.data) { @@ -173,11 +179,7 @@ $.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { qx = $.param(optionsData, 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]);