我在页面加载时使用jQuery的“模态”对话框弹出窗口来显示消息,并且在关闭模态时,我正在显示我的页面,页面上有几个按钮。
当我单击这些按钮中的任何一个时,将打开模式对话框,并在页面上的所有click_event上打开。我不确定如何在同一页面的每个click_event上停用模式对话框。
<script>
$(document).ready(function () {
$("#dialog-confirm").dialog({
resizable: false,
height: 189,
width: 500,
modal: true,
buttons: {
Agree: function () {
$(this).dialog("close");
}
}
});
});
</script>
和我的HTML是:
<div id="dialog-confirm" title="PLEASE READ BEFORE PROCEDDING"
style="font-weight: bold">
<p>Documentation is MANDATORY!</p>
<p>Please remember to list the PCP and Radiology Services Visited with the
and TIME included. Please select “Agree” to continue.
</p>
</div>
我在这个论坛上搜索了类似的问题,但是没有找到任何解决方案。
任何帮助表示赞赏。
最佳答案
请尝试以下操作:
将您的JavaScript更改为以下内容:
<script>
$(document).ready(function () {
confimationDialogShow: function() {
$("#dialog-confirm").dialog({
resizable: false,
height: 189,
width: 500,
modal: true,
buttons: {
Agree: function () {
$(this).dialog("close");
}
}
});
}
});
</script>
在服务器上的Page_Load方法中执行以下操作:
if (!Page.IsPostBack)
{
ScriptManager.RegisterStartupScript(this,this.GetType(), "Javascript", "javascript: confimationDialogShow();", true);
}
因此,每次您第一次加载页面时,都可以触发启动脚本并显示对话框。页面上的后续邮箱将不再显示该对话框。因为调用该脚本的脚本仅在IsPostBack值为false时才会启动。
快乐编码!
更新
嗨,罗恩,让我们尝试将其从$(document).ready()中删除。改为这样做。
<script>
function confirmationDialogShow() {
$("#dialog-confirm").dialog({
resizable: false,
height: 189,
width: 500,
modal: true,
buttons: {
Agree: function () {
$(this).dialog("close");
}
}
});
}
</script>
查看Register脚本是否立即调用它。顺便说一句-您的对话框不是这样的asp:UpdatePanel吗?