Ajax.BeginForm没有隐瞒装载元素时onBegin失败 [英] Ajax.BeginForm not hiding loading element when onBegin fails

查看:384
本文介绍了Ajax.BeginForm没有隐瞒装载元素时onBegin失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的MVC应用程序的Ajax.BeginForm帮手。这里有一个简单的例子:

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"
           }))
       { %>

问题是,如果OnBegin回调返回false,从而正确prevents从所取得的Ajax调用,加载元素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.

我用onFailure处和的onComplete回调试过,但如果OnBegin回调失败这些都不被调用。

I've tried using the OnFailure and OnComplete callbacks, but neither of these are called if the OnBegin callback fails.

有趣的是,加载元素才会显示的之后的的OnBegin功能又回来了。

Interestingly the loading element is not displayed until after the OnBegin function has returned.

我可以通过明确的显示和隐藏AJAX加载元素自定义JavaScript函数解决这个问题,但是这看起来像是助手确实应该照顾我。

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.

推荐答案

尝试设置上的负载div来没有显示风格。防爆。 ..your加载图片

try setting the display style on the loading div to none. Ex. ..your loading pic

这篇关于Ajax.BeginForm没有隐瞒装载元素时onBegin失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆