From 882225c5cce8923ea599e296d8829401dcfe510d Mon Sep 17 00:00:00 2001 From: SG5 Date: Tue, 29 Oct 2019 22:20:23 -0700 Subject: [PATCH] add beforeFormUnbind callback, fix #372 --- README.md | 9 +++++++++ src/jquery.form.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 1be69729..c975836f 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,15 @@ beforeSubmit: function(arr, $form, options) { } ```` +### beforeFormUnbind +Callback function invoked before form events unbind and bind again. Provides an opportunity to manipulate the form before events will be remounted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object. + +````javascript +beforeFormUnbind: function($form, options) { + // your callback code +} +```` + ### filtering Callback function invoked before processing fields. This provides a way to filter elements. diff --git a/src/jquery.form.js b/src/jquery.form.js index a1d0a428..022f703c 100644 --- a/src/jquery.form.js +++ b/src/jquery.form.js @@ -1012,6 +1012,10 @@ return this; } + if (options.beforeFormUnbind) { + options.beforeFormUnbind(this, options) + } + return this.ajaxFormUnbind() .on('submit.form-plugin', options, doAjaxSubmit) .on('click.form-plugin', options, captureSubmittingElement);