I'm using the Ajax.BeginForm helper in my MVC app. Here's a simplified example:
<% using (Ajax.BeginForm("actionName", new { Controller = "controller" }, new AjaxOptions
{
OnBegin = "doValidation",
LoadingElementId = "ajaxLoader"
}))
{ %>
The problem is that if the OnBegin callback returns false, which correctly prevents the ajax call from being made, the loading element "ajaxLoader" is still displayed, and not hidden.
I've tried using the OnFailure and OnComplete callbacks, but neither of these are called if the OnBegin callback fails.
Interestingly the loading element is not displayed until after the OnBegin function has returned.
I can get around this by explicitly showing and hiding the ajax loading element in custom javascript functions, but this seems like something the helper should really take care of for me.