【发布时间】:2014-07-16 19:36:33
【问题描述】:
我有一个 .aspx 页面,它使用 Eric Martin 的 SimpleModal 插件在弹出窗口中打开另一个 .aspx 页面。我可以使用右上角的小 x 关闭弹出表单,但还需要能够通过单击按钮以编程方式关闭表单。我正在使用推荐的 $.modal.close() 但它似乎不起作用——弹出窗口没有关闭。
这是我在 c# 中从父页面打开表单的方法:
ClientScript.RegisterStartupScript(this.Page.GetType(), "Popup", "$(document).ready(function () {simpleModal('555','300','mypopuppage.aspx');});", true);
在弹出页面的代码隐藏中,在按钮的点击事件中,这就是我试图关闭弹出窗口的方式(这不起作用):
ClientScript.RegisterStartupScript(this.Page.GetType(), "ClosePopUp", "<script type='text/javascript'>$.modal.close();</script>", true);
我的 SimpleModal 函数如下所示:
function simpleModal(smWidth, smHeight, smLink) {
var str = '<iframe id="modaliframe" src="' + smLink + '" height="' + smHeight + '" width="' + smWidth + '" style="border:0">';
$.modal(str, {
closeHTML: "<a href='#' class='close' alt='Close' title='Close'></a>",
containerCss: {
backgroundColor: "#fff",
height: smHeight,
padding: 0,
width: smWidth
},
overlayClose: false,
closeClass: "close",
onClose: refreshParent,
onShow: bindLoginButtons
});
return false;
}
function refreshParent() {
window.location.reload(true);
$.modal.close();
}
谁能告诉我我做错了什么?
谢谢。
做了一些更深入的调试,我能够将问题定位到插件关闭函数中的未定义对象。我不知道它怎么可能是未定义的,因为我已经包含了正确的库并且其他一切都有效。这是功能。 “this.d.data”是未定义的。
close: function () {
if (!this.d.data) return !1;
this.unbindEvents();
if (b.isFunction(this.o.onClose) && !this.occb) this.occb = !0, this.o.onClose.apply(this, [this.d]);
else {
if (this.d.placeholder) {
var a = b("#simplemodal-placeholder");
this.o.persist ? a.replaceWith(this.d.data.removeClass("simplemodal-data").css("display", this.display)) : (this.d.data.hide().remove(), a.replaceWith(this.d.orig))
} else this.d.data.hide().remove();
this.d.container.hide().remove();
this.d.overlay.hide();
this.d.iframe && this.d.iframe.hide().remove();
this.d.overlay.remove();
this.d = {}
}
}
【问题讨论】:
-
尝试检查示例的源代码
-
你可以试试:$("#modaliframe").dialog("close");
-
谢谢,Dasha,很遗憾那没有用。
标签: c# jquery asp.net simplemodal