我有一个div,上面有一些东西,我想要弹出给用户,这样他们在提交之前必须同意:
<div id="terms" style="display:none">
<p style="font-weight:bold">If your data is not backed up in advance, you may have to forfeit your booked slot and rebook the handover on another date.</p>
<asp:CheckBox ID="cbTerms" ClientIDMode="Static" CssClass="error" Style="font-size:0.8em" Text =" I understand the above, and will ensure my data is backed up prior to the handover date" runat="server" />
<p style="text-align:right"><asp:Button ID="btnSubmit" ClientIDMode="Static" runat="server" Text="Submit" OnClick="btnSubmit_Click" Enabled="False" /></p>
</div>
我使用jQuery UI对话框来实现这一点:
$('#terms').css('visibility','block');
$('#terms').dialog({
modal: true,
width: '500px',
title: 'IMPORTANT! Remember To Backup Your Laptop',
open: function (event, ui) {
$('.ui-dialog-titlebar-close').hide();
$(this).parent().appendTo('form'); },
});
如果我省略了:
$(this).parent().appendTo('form'); }
该按钮将不会触发,因为它一直在窗体外部。
然而,当我把它放进去使按钮工作时,表单出现在模式覆盖的后面,并且无法点击。
我使用的是母版页--不确定这是否相关。
发布于 2013-06-28 14:48:37
我会将对话框添加到文档节点,并将事件处理程序添加到调用form.submit()
的按钮。
发布于 2013-08-24 13:48:59
这似乎只有在使用最新版本的JQuery时才会发生,而且如果您使用append选项。
不幸的是,当控件位于UpdatePanel中时,从JQuery提交表单会导致刷新整个页面。
这段代码将允许您通过设置覆盖和对话框上的z索引,将对话框附加到窗体中,并将覆盖保留在其后面。
open: function (type, data) {
$('.ui-dialog').css('z-index', 103);
$('.ui-widget-overlay').css('z-index', 102);
$(this).parent().appendTo("form");
}
https://stackoverflow.com/questions/17367420
复制