我正在使用一个小型 MVC 3 应用程序,并且我已经在我的 ajax 提交表单上设置了 LoadingElementDuration 参数,但似乎它根本没有任何效果。如果我将其设置为 1 或 5000,动画始终以相同的速度播放。
这是一个已知的错误还是其他什么?
这是我的 View 代码,部分摘自“Pro ASP.NET MVC 3 Framework”;动画不会持续 5 秒:
@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>
}
最佳答案
我稍微调整了库代码,看起来这确实是一个错误。
问题出在 jquery.unobtrusive-ajax.js 的以下代码行中:
duration = element.getAttribute("data-ajax-loading-duration") || 0;
如果我将其更改为:
duration = parseInt(element.getAttribute("data-ajax-loading-duration")) || 0;
动画播放正确。当它是数字时,jQuery show 中的 duration 参数函数应该是一个整数,而不是一个字符串。
他们可能应该在官方库中更改此设置。我希望这可以帮助其他人。
关于jquery - ASP.NET MVC 3 LoadingElementDuration 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8928671/