1

我的页面上有多个链接,每个链接都会打开一个不同的 UI 对话框,

这是对话框代码:

$('#photo-form').dialog({
    autoOpen: false,
    modal:true,
    width: 500,
    height:460,
    buttons: {
        "Save": function() {
            // do some action 
            $(this).dialog('close'); // Close the Confirmation Box
        },
        "Cancel": function() {
            //if the User Clicks the button "cancel"
            $(this).dialog('close');
        }
    }
});

// if a user clicks on the "delete" image
$('a.album').click(function(e) {
    $('#photo-form').dialog('open');
});

我的问题是,一旦我打开第一个对话框,然后完成我需要对其执行的操作,然后单击保存或取消将其关闭,

第一:当我单击第二个对话框的链接时,除非我重新加载页面并且我不想这样做,否则它不会打开。

第二:当我尝试再次打开同一个对话框时,它会打开前一个瞬间,我需要重置它。

当我尝试使用$(this).dialog('destroy')if$(this).dialog('close')来关闭第一个对话框时,我可以打开第二个对话框,但是当我单击第一个对话框的链接时,我无法再次打开它。

4

1 回答 1

0

我无法弄清楚你的确切意思。

试试这个jsfiddle

http://jsfiddle.net/Doinkmeister/gZBgR/

有 2 个对话框,都在单击时打开。

还请提供您的 html 代码,因为问题可能存在。

$(this).dialog('close'); 应该做的伎俩。

是您在 document.ready() 中的所有代码

尝试将所有代码添加到

$(function(){
    $('#photo-form').dialog({
        autoOpen: false,
        modal:true,
        width: 500,
        height:460,
        buttons: {
           "Save": function() {
               // do some action 
               $(this).dialog('close'); // Close the Confirmation Box
            },
            "Cancel": function() {
                //if the User Clicks the button "cancel"
                $(this).dialog('close');
            }
        }
    });

    $('a.album').click(function(e) {
        $('#photo-form').dialog('open');
    });
});
于 2012-10-23T06:34:21.293 回答