ASP.NET MVC 3 LoadingElementDuration不工作? [英] ASP.NET MVC 3 LoadingElementDuration not working?
问题描述
我玩的小MVC 3应用程序,我已经将 LoadingElementDuration 我的AJAX提交的表单参数,但它似乎没有任何效果可言。如果我将它设置为1或5000,动画总是扮演以相同的速度的。照片 它是一个已知的bug还是什么?
感谢。
卢卡
编辑:这是我的看法code,它是部分取自临ASP.NET MVC 3框架;动画不会持续5秒:
@model IEnumerable的< MvcAjax.Models.Appointment>
@ {
ViewBag.Title =预约单;
}
< H2>任命名单,其中,/ H>
@using(Ajax.BeginForm(新AjaxOptions {UpdateTargetId =tabledata,LoadingElementId =装载,LoadingElementDuration = 5000}))
{
&其中,P ID =装的风格=字体大小:70px;背景色:红色;显示:无;溢出:隐藏;>从服务器...&LT负载的数据; / P>
<表>
< THEAD>
&其中; TR>
<第i个客户端名称和LT; /第i个
<第i个预约时间和LT; /第i个
< / TR>
< / THEAD>
< TBODY ID =tabledata>
@ Html.Partial(AppointmentData,模型)
< / TBODY>
< /表>
< DIV>
@ Html.DropDownList(ID,新的SelectList(新[] {全部,乔,简,鲍勃},ViewBag.SelectedValue ??全部))
<输入类型=提交值=提交/>
< / DIV>
}
我调整了一下库code,似乎它确实是一个错误。
问题是在code从以下行的 jquery.unobtrusive-ajax.js 的:
时间= element.getAttribute(数据AJAX加载持续时间)|| 0;
如果我将其更改为:
时间= parseInt函数(element.getAttribute(数据AJAX加载持续时间))|| 0;
动画可以正常播放。当它是一个数字,时间的在jQuery的显示函数的参数应该是一个整数,而不是一个字符串。
他们或许应该在官方库中进行更改。我希望这可以帮助其他人。
I am playing with a small MVC 3 application and I have set the LoadingElementDuration parameter on my ajax-submitted form but it seems that it has no effect at all. If I set it to 1 or 5000, the animation is always played at the same speed.
Is it a known bug or something?
Thanks.
Luca
EDIT: here is my view code, it is partially taken from "Pro ASP.NET MVC 3 Framework"; the animation doesn't last for 5 seconds:
@model IEnumerable<MvcAjax.Models.Appointment>
@{
ViewBag.Title = "Appointment List";
}
<h2>Appointment List</h2>
@using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "tabledata", LoadingElementId = "loading", LoadingElementDuration = 5000 }))
{
<p id="loading" style="font-size: 70px; background-color: Red; display: none; overflow: hidden;">Loading data from server...</p>
<table>
<thead>
<tr>
<th>Client Name</th>
<th>Appointment Date</th>
</tr>
</thead>
<tbody id="tabledata">
@Html.Partial("AppointmentData", Model)
</tbody>
</table>
<div>
@Html.DropDownList("id", new SelectList(new[] { "All", "Joe", "Jane", "Bob" }, ViewBag.SelectedValue ?? "All"))
<input type="submit" value="Submit" />
</div>
}
I tweaked a bit the library code and it seems that it is really a bug.
The problem is in the following line of code from jquery.unobtrusive-ajax.js:
duration = element.getAttribute("data-ajax-loading-duration") || 0;
If I change it to:
duration = parseInt(element.getAttribute("data-ajax-loading-duration")) || 0;
The animation plays correctly. When it's a number, the duration argument in the jQuery show function is supposed to be an integer, not a string.
They probably should change this in the official library. I hope this can help other people.
这篇关于ASP.NET MVC 3 LoadingElementDuration不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!