Jquery 对话框 - div 初始化后消失

标签 jquery modal-dialog jquery-ui-dialog

JQuery Dialog 最近给我带来了很多痛苦。 我有以下要弹出的 div。 (忽略类在语法中不显示双引号)

TABLE class=widget-title-table border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
    <TD class=widget-title><SPAN class=widget-title>Basic Info</SPAN></TD>
    <TD class=widget-action>
    <DIV id=edit-actions jQuery1266325647362="3">
        <UL class="linkbutton-menu read-mode">
            <LI class="control-actions">
                <A id="action-button" class="mouse-over-pointer linkbutton">Delete this                 stakeholder</A> 
            <DIV id="confirmation" class="confirmation-dialog title=Confirmation">
                Are you sure you want to delete this stakeholder? 
            </DIV>

</LI></UL></DIV></TD></TR></TBODY></TABLE>

用于此的 JQuery 是...

$(document).ready(function() {

$('#confirmation').dialog({
    bgiframe: true, modal: true, autoOpen: false, closeOnEscape: false,
    draggable: true, position: 'center', resizable: false, width: 400, height: 150
    });

});

对话框是由

打开的
var confirmationBox = $('#confirmation',actionContent);
if (confirmationBox.length > 0) {


    //Confirmation Needed
    $(confirmationBox).dialog('option', 'buttons', {
        'No': function() {
            $(this).dialog('close');
        },
        'Yes': function() {
            $('ul.read-mode').hide();
            $.post(requestUrl, {}, ActionCallback(context[0], renderFormUrl), 'json');
            $(this).dialog('close');
        }            
    });

    $(confirmationBox).dialog('open');

}

问题始于初始化本身。 加载文档时,<div #confirmation>已从标记中删除! 我之前遇到过类似的问题,但我不能在这里使用该解决方案。 在此页面上我可以有多个 PopUp div。

当我在打开它之前添加初始化时;表格弹出。但是当我关闭它之后,div就被删除了;所以我无法再次看到弹出窗口。

最佳答案

您看到它删除#confirmation的原因是因为$("#foo").dialog()会将#foo从DOM中的任何位置移动到文档的底部创建最初隐藏的对话框样式的包装元素内部。据了解,对话框在打开之前是隐藏的。

关于Jquery 对话框 - div 初始化后消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2272961/

相关文章:

jquery - 重绘数据表的正确方法?出现错误 : "no method ' fnDraw '"and "cannot read property 'oFeatures' "

javascript - bootstrap javascript 需要 jquery 错误

javascript - 测量 Javascript 应用程序的 CPU 负载

user-interface - 为什么模态/非模态对话框称为模态/非模态?

javascript - 为什么我的 window.dialogArguments 未定义

jquery-ui - 动画 jQuery UI 对话框自动调整大小

javascript - ScrollTo 适用于所有浏览器,但完整回调会多次触发

javascript - 显示模式窗口时阻止其他页面元素的功能

asp.net - 在文档准备好后将 jQuery UI 对话框附加到 ASP.NET 表单

javascript - jQuery UI 模态对话框 : Close and Resize Icons in Wrong Place