0

我正在使用 jdialog,一切正常,但是当我多次显示相同的 div 时,它会冻结,如果我刷新页面,一切都会再次正常。

我什至尝试为 div 生成动态 id

这里的代码:

/* * */ function open_jdialog(url, div_id,dialog_title, dialog_width, dialog_height,top_position) { try { if (trim(div_id)=="") { div_id="host_div_id" }

    if (typeof(top_position)==='undefined')
    {
        top_position=100
    }

    host_div=document.getElementById(div_id)
    key=generate_key();
    host_div.innerHTML="<div id=" + key + "></div>"

    url=url + "&div_to_close=" + key



    get_data_via_ajax( url ,key)//get
    //

    if (dialog_width==0) dialog_height="auto"
    if (dialog_height==0) dialog_height="auto"

    //
    $("#" + key).dialog({
    width: dialog_width,
    height: dialog_height,//$(window).height(),
    modal: true,
    title:dialog_title,
    position: ["centre",top_position],
    zIndex: 0,
    });

    $('#' + key).bind('dialogclose', function(event) 
    {
        document.getElementById(div_id).innerHTML=""
        //document.getElementById(div_id).reset();
    });



}//end try
catch(err)
{

}

}

4

1 回答 1

0

If it is to prevent multiple instances being created, then just use the following approach...

$('#myDialog') 
.dialog( 
{ 
    title: 'Error', 
    close: function(event, ui) 
    { 
        $(this).dialog('close');
    } 
}); 
于 2013-08-18T16:13:08.607 回答