Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery模态对话框加载xhtml页面,但不关闭_Jquery_Jquery Dialog - Fatal编程技术网

jquery模态对话框加载xhtml页面,但不关闭

jquery模态对话框加载xhtml页面,但不关闭,jquery,jquery-dialog,Jquery,Jquery Dialog,我有一个模式对话框,当点击一个按钮时打开,打开时加载一个.xhtml页面 在这个XHTML页面中,我有一个按钮,用于将一些数据传递回父窗口(对话框在父窗口中初始化),然后我想关闭对话框,但它不会关闭!!这是我的代码: 第一页: <script type="text/javascript"> var selected_row_data_json; window.lang = new jquery_lang_js();

我有一个模式对话框,当点击一个按钮时打开,打开时加载一个
.xhtml
页面

在这个XHTML页面中,我有一个按钮,用于将一些数据传递回父窗口(对话框在父窗口中初始化),然后我想关闭对话框,但它不会关闭!!这是我的代码:

第一页:

<script type="text/javascript">                         
    var selected_row_data_json;

    window.lang = new jquery_lang_js();

    $().ready(function () {
        $.ajaxSetup ({
            // Disable caching of AJAX responses
            cache: false
        });
        createDataListDialog();                
    });     

    function setSelectedRowJsonData(row_data_)
    {  
       selected_row_data_json = row_data_;                           
    }           

    function setFormSelectedValues()
    {
        $('#dataListDialog').dialog('close');  
    }

    function createDataListDialog()
    {
        $("#dataListDialog").dialog(
        {                   
            autoOpen: false,                      
            modal: true,                    
            resizable: true,
            open: function (event, ui) {   
            /* <![CDATA[ */                    
                $('#dataListDialog').css('overflow', 'hidden');

                $('body').css('overflow','hidden');
                $(this).load("data_list.xhtml");                       
            /* ]]> */
            },
            height: 400,
            width: 550,
            close: function (event, ui) {                        
                $(this).dialog('destroy');
                createDataListDialog();                        
            },
            create: function(event, ui)   
            {                                                  
                $(this).parents(".ui-dialog").css("padding", 0);                           
                $(this).parents(".ui-dialog:first")
                    .find(".ui-dialog-content").css("padding", 0);
            }
        });       
    }
</script>

<f:view>
    <h:outputLabel value="Code:"  lang="en" onclick="openDialog('dataListDialog');return false;" />

    <div id="dataListDialog" lang="en" title="Users" dir="#{user.dir}">                
    </div>
</f:view>
我做错什么了吗?遗漏了什么?为什么对话框没有从加载的页面关闭

更新: 如果加载的页面是
html
页面,那么它工作正常-对话框正在关闭。问题是当页面是
xhtml
page。。我怎样才能解决这个问题


任何帮助都将不胜感激

一种更简单的方法是在加载成功完成后启动
test()
函数,即将其绑定到
complete
事件:

$(this).load("data_list.xhtml",
    complete: function(response, status, xhr) {
        window.parent.setSelectedRowJsonData(selected_row_data_json);
        window.parent.setFormSelectedValues();
    });   

额外好处:使用
状态对象添加一些处理服务器错误的条件。

看起来像是在关闭事件中调用
createDataListDialog()
。它看起来像是每次关闭时都会重新创建对话框。
$(this).load("data_list.xhtml",
    complete: function(response, status, xhr) {
        window.parent.setSelectedRowJsonData(selected_row_data_json);
        window.parent.setFormSelectedValues();
    });