mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-19 12:35:32 +08:00
Fixing multi-submission differently
Take into account dynamic forms Client validation
This commit is contained in:
parent
ac3a0387fa
commit
8ebf58d27d
@ -8,7 +8,7 @@
|
|||||||
Layout.Title = T("New {0}", Html.Raw(typeDisplayName)).Text;
|
Layout.Title = T("New {0}", Html.Raw(typeDisplayName)).Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Create", new { ReturnUrl = Request.QueryString["ReturnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
@using (Html.BeginFormAntiForgeryPost(Url.Action("Create", new { ReturnUrl = Request.QueryString["ReturnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data", @class = "no-multisubmit" })) {
|
||||||
@Html.ValidationSummary()
|
@Html.ValidationSummary()
|
||||||
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
||||||
@Display(Model)
|
@Display(Model)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
Layout.Title = pageTitle;
|
Layout.Title = pageTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Edit"), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
@using (Html.BeginFormAntiForgeryPost(Url.Action("Edit"), FormMethod.Post, new { enctype = "multipart/form-data", @class= "no-multisubmit" })) {
|
||||||
@Html.ValidationSummary()
|
@Html.ValidationSummary()
|
||||||
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
||||||
@Display(Model)
|
@Display(Model)
|
||||||
|
@ -81,14 +81,30 @@
|
|||||||
$("input[type=checkbox]:not(:disabled)").prop('checked', $(this).prop("checked"))
|
$("input[type=checkbox]:not(:disabled)").prop('checked', $(this).prop("checked"))
|
||||||
});
|
});
|
||||||
|
|
||||||
//Prevent double-click on buttons of type "submit"
|
//Prevent multi submissions on forms
|
||||||
$("form button[type='submit'], form input[type='submit']").click(function (e) {
|
$("body").on("submit", "form.no-multisubmit", function (e) {
|
||||||
var form = $(this).closest("form")[0];
|
var submittingClass = "submitting";
|
||||||
if (typeof(form.formSubmitted) != "undefined") {
|
form = $(this);
|
||||||
|
|
||||||
|
if (form.hasClass(submittingClass)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
form.formSubmitted = true;
|
|
||||||
|
form.addClass(submittingClass);
|
||||||
|
|
||||||
|
buttons = form.find("[type='submit']");
|
||||||
|
buttons.prop("disabled", true)
|
||||||
|
|
||||||
|
// safety-nest in case the form didn't refresh the page
|
||||||
|
setTimeout(function () {
|
||||||
|
form.removeClass(submittingClass);
|
||||||
|
buttons.prop("disabled", false)
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle keypress events in bulk action fieldsets that are part of a single form.
|
// Handle keypress events in bulk action fieldsets that are part of a single form.
|
||||||
|
Loading…
Reference in New Issue
Block a user