我在页面加载时使用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>
查看注册脚本现在是否会调用它。顺便说一句 - 你的对话框不是在asp:UpdatePanel中吗?
由于缺少带有按钮的页面的HTML代码,我只是猜测。
将Agree
放在引号中,就像在本例中所做的那样。
buttons: {
"Agree": function () {
$(this).dialog("close");
}
}
否则,您的函数可能应用于页面上的所有按钮。