mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-17 01:57:25 +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;
|
||||
}
|
||||
|
||||
@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()
|
||||
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
||||
@Display(Model)
|
||||
|
@ -8,7 +8,7 @@
|
||||
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()
|
||||
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
|
||||
@Display(Model)
|
||||
|
@ -81,14 +81,30 @@
|
||||
$("input[type=checkbox]:not(:disabled)").prop('checked', $(this).prop("checked"))
|
||||
});
|
||||
|
||||
//Prevent double-click on buttons of type "submit"
|
||||
$("form button[type='submit'], form input[type='submit']").click(function (e) {
|
||||
var form = $(this).closest("form")[0];
|
||||
if (typeof(form.formSubmitted) != "undefined") {
|
||||
//Prevent multi submissions on forms
|
||||
$("body").on("submit", "form.no-multisubmit", function (e) {
|
||||
var submittingClass = "submitting";
|
||||
form = $(this);
|
||||
|
||||
if (form.hasClass(submittingClass)) {
|
||||
e.preventDefault();
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user