ASP.NET MVC 3 Jquery 模态弹出窗口 - 显示加载图标
各位,
我有 ASP.NET MVC 3 应用程序,并且下面有以下 JQuery 脚本来显示模式弹出窗口。以下脚本能够显示模式对话框。但是,我想在模式对话框打开时加载加载图标。你知道我该怎么做吗?
<%= Html.ActionLink("Details", "ProductShipping", "OnlineStore", new { ProductGUID = Html.Encode(Model.GUID) }, new { @class = "EditShippinglink", title = "Edit Product Shipping", data_dialog_id = "EditProductShipping", data_dialog_title = "Shipping Method" })%>
JQuery
$(".EditShippinglink").live("click", function (e) {
$.ajaxSetup({ cache: false });
e.preventDefault();
var $loading = $('<img src="/Content/ajax-loader.gif" alt="loading" class="ui-loading-icon">');
$("<div></div>")
.addClass("dialog")
.attr("id", $(this)
.attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove() },
width: 900,
modal: true,
minHeight: 500,
show: 'fade',
hide: 'fade',
resizable: 'false'
})
.load(this.href);
});
Folks,
I have ASP.NET MVC 3 Application and I have the following JQuery script below to show modal pop up windows. The following script is able to show modal dialog. However, I would like to load loading icon while the modal dialog is opening. do you have any idea how can I do it?
<%= Html.ActionLink("Details", "ProductShipping", "OnlineStore", new { ProductGUID = Html.Encode(Model.GUID) }, new { @class = "EditShippinglink", title = "Edit Product Shipping", data_dialog_id = "EditProductShipping", data_dialog_title = "Shipping Method" })%>
JQuery
$(".EditShippinglink").live("click", function (e) {
$.ajaxSetup({ cache: false });
e.preventDefault();
var $loading = $('<img src="/Content/ajax-loader.gif" alt="loading" class="ui-loading-icon">');
$("<div></div>")
.addClass("dialog")
.attr("id", $(this)
.attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove() },
width: 900,
modal: true,
minHeight: 500,
show: 'fade',
hide: 'fade',
resizable: 'false'
})
.load(this.href);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将模式对话框的初始 HTML 设置为您想要显示的内容,直到 ajax 请求完成并更改弹出窗口的内容。
不要从一个空的 div 开始
$('
')
,而是使用加载了您想要在加载时显示的 html 的 div 。然后,当显示对话框但仍在等待加载完成时,将显示加载 gif。一旦操作完成,加载将覆盖动画加载gif html。
Set the initial HTML of the modal dialog to be what you want to show until the ajax request completes and changes the content of the popup's window.
Rather than having an empty div to start with,
$('<div></div>')
, use a div that is loaded with the html you want to show while the load is occurring.Then when the dialog is shown but still waiting for the load to complete, the loading gif will be shown. Once the operation is complete, the load will overwrite the animated loading gif html.