Reputation: 1020
Got a working AJAX form:
@using (Ajax.BeginForm(...))
I want to disable the button while result is loading. If I use this:
$("#submit").click(function () { $("#submit").button().attr('disabled', true).addClass('ui-state-disabled'); })
It disables the button, but form doesnt send anything to the controller. How can I fix that? (and yes, I barely know how to use JS)
Upvotes: 4
Views: 4218
Reputation: 153
This would do the trick:
$(document).ajaxStart(function () {
$("#submit").prop("disabled", true);
});
And then if you need to make it enabled when done:
$(document).ajaxStop(function () {
$("#submit").prop("disabled", false);
});
Upvotes: 7
Reputation: 6882
do you have anything in here (...) -> @using (Ajax.BeginForm(...))
consider using the options to register AjaxOptions @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "result" }))
you should have to options at least if you are using the jqery helpers
beforeSubmit: CallBackToHandleThinksPreSubmit, // pre-submit callback
success: CallBackToHandleThinksPostSubmit// post-submit callback
I would register to a callback an make the visibility changes...
HTH
Upvotes: 0