繁体   English   中英

不能多次打开jquery对话框

[英]Can't open more than once jquery dialog

我有一个jQuery对话框,在我有:

$(document).ready(function() {
if( window.location.href.indexOf( '#product' ) != -1 ) {
    var productID = window.location.href.split('-');
    showDialog(productID[1]);
}

});

function showDialog(productID)
{
    $( "#dialog-modal_"+productID ).html( "<iframe src='index.php?act=showProduct&amp;id="+productID+"' width='100%' height='100%' frameborder='0' scrolling='no'></iframe>" );
    $( "#dialog-modal_"+productID ).dialog({
    width: 790,
    height: 590,
    modal: true,
    open: function(event, ui)
    {

    }
    });

}

当我打开它时它工作正常,但是如果我关闭该窗口并尝试重新打开它-它没有响应。

谢谢!!

以下是jQuery UI对话框代码应如何出现的示例。 请记住,您需要一种打开对话框的方法。 因此,创建一个在该模式下再次调用showDialog的函数。 一个按钮或链接将起作用。

jQuery UI代码

function showDialog(productID)
{
    var container = $('#dialog-modal_'+productID).html('<blah blah>');
    container.dialog({
        autoOpen: false,
        modal: true,
        width: 790,
        height: 590
    });
    container
        .dialog('option', 'title', 'Your Title')
        .dialog('option', 'buttons', {
            Close: function() {
                $(this).dialog('close');
            }
        })
        .dialog('open');
        //do open event work here
}

打开按钮的DOM

<a href="#null" id="open">Open My Modal</a>

jQuery的打开按钮

$('a#open').click(function(e) {
    e.preventDefault();
    showDialog(<your id>);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM