Fixes #5124: Added support to prevent duplicated form submission when using ActiveForm

This commit is contained in:
Qiang Xue
2014-09-22 12:19:11 -04:00
parent ac7e3bdbed
commit 82037bc70e
2 changed files with 7 additions and 2 deletions

View File

@ -349,11 +349,15 @@
data = $form.data('yiiActiveForm');
if (data.validated) {
if (!data.submitting) {
// form is being submitted. Do nothing to avoid duplicated form submission
return false;
}
data.submitting = false;
var event = $.Event(events.beforeSubmit);
$form.trigger(event, [$form]);
$form.trigger(event);
if (event.result === false) {
data.validated = false;
data.submitting = false;
return false;
}
return true; // continue submitting the form since validation passes