提交我现在有一个登录表单显示如下:显示装载机MVC
+----------------------------------+
| |
| +----------+ |
| | E: | |
| | P: | |
| | SUBMIT | |
| +----------+ |
| LOADER |
| |
+----------------------------------+
表单定义:
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post))
{
@Html.AntiForgeryToken()
<form action="" id="test">
我的提交按钮显示如下:
<div>
<input type="submit" value="Log in" onclick="OpenSite();" />
<a>@Html.ActionLink("Forgot your password?","ForgotPassword","Account")</a>
</div>
加载程序:
<div class="loader" id="myLoader" style="display:none">Loading...</div>
随着“OpenSite”功能:
<script>
function OpenSite() {
$('.loader').show();
$('#openPopup').click();
};
</script>
我怎么能强迫此功能在提交表单之前执行,但是当我按下“Submit
”按钮?
即:
+---------------+
User Fills form
+---------------+
||
\/
+---------------+
User Presses
submit
+---------------+
||
\/
+---------------+
Display loader
+---------------+
||
\/
+---------------+
Display popup
+---------------+
||
\/
+---------------+
Submit form
to controller
+---------------+
这意味着,尽管接下来的页面加载“加载”动画显示。
这是如何实现的?
我尝试添加一个alert("hello world");
到函数的开始,它执行的,但我的加载程序未显示在所有:(
任何帮助,将不胜感激
我也曾尝试:
$("#test").submit(function (event) {
$('#myLoader').show();
});
没有运气
您是否尝试过在表单提交事件中显示它? – filur 2014-11-25 10:08:04
就像@filur建议的一样,你需要使用“onsubmit”事件 – Th0rndike 2014-11-25 10:14:18
已经尝试过了,没有成功。 – jbutler483 2014-11-25 10:15:45