Jquery Modal 弹出窗口在第二次单击时打开,而不是在第一次单击时打开
我被 jquery 模态对话框卡住了。我的模式通过单击按钮两次来显示,并且也会破坏页面上的标记 我没有读过任何帖子,包括堆栈溢出 这个
和 这个
但我的问题两者都不匹配。所以我请求您不要投票否决这个问题。
我正在使用以下代码来显示模态,
<script type="text/javascript">
function overlayclickclose() {
if (closedialog) {
jQuery('#mydialog').dialog('close');
}
closedialog = 1;
}
jQuery('#mydialog').dialog({
bgiframe: true,
autoOpen: false,
modal: true,
width: 900,
height: 400,
resizable: false,
open: function() { closedialog = 1; jQuery(document).bind('click', overlayclickclose); },
focus: function() { closedialog = 1; },
close: function() { jQuery(document).unbind('click'); }
});
</script>
现在这里是我的 div 将显示为弹出窗口
<div id="mydialog"><NL:TemplatePicker ID="TemplatePicker1" Runat="server"></NL:TemplatePicker></div>
,我通过在 asp.net 代码后面调用它来在单击按钮时调用模态,就像
protected void btnChooseTemplate_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "change", "jQuery('#mydialog').dialog('open');closedialog = 1;jQuery('#mydialog').parent().appendTo(jQuery('form:aspnetForm'));", true);
}
我的页面使用 ajax updatepanel 一样。
任何帮助都会受到重视。如果您需要更多信息来更好地了解问题,请告诉我。
谢谢
i got stuck with jquery modal dialog. my modal shows by clicking twice on the button and spoils the markup also on the page
i read no of posts including stack overflow
this
AND this
but my issue doesn't match both.So i request you to please not vote down the question.
i am using the following code to show modal
<script type="text/javascript">
function overlayclickclose() {
if (closedialog) {
jQuery('#mydialog').dialog('close');
}
closedialog = 1;
}
jQuery('#mydialog').dialog({
bgiframe: true,
autoOpen: false,
modal: true,
width: 900,
height: 400,
resizable: false,
open: function() { closedialog = 1; jQuery(document).bind('click', overlayclickclose); },
focus: function() { closedialog = 1; },
close: function() { jQuery(document).unbind('click'); }
});
</script>
now here is my div to be shown as popup
<div id="mydialog"><NL:TemplatePicker ID="TemplatePicker1" Runat="server"></NL:TemplatePicker></div>
And i am calling the modal on Click of a button by calling it in asp.net code behind like this
protected void btnChooseTemplate_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "change", "jQuery('#mydialog').dialog('open');closedialog = 1;jQuery('#mydialog').parent().appendTo(jQuery('form:aspnetForm'));", true);
}
my page uses ajax updatepanel.
any help would be regarded. if you need anything more to knowthe problem better let me know.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Devjosh:看起来您正在 btnChooseTemplate 单击中注册打开的对话框。这意味着打开的脚本只有在第一次单击后才会注册。尝试将客户端脚本块注册移动到页面加载函数中,以便每次页面加载时都会注册它,为每次第一次单击做好准备。
@Devjosh: It looks like you are registering the open dialog in the btnChooseTemplate click. This means the open script will not be registered until after the first click. Try moving the client script block registration into the page load function so that it's registered each time your page loads, ready for the first click each time.