JQuery刷新UI对话框的内容?

时间:2011-09-14 09:15:53

标签: jquery asp.net

当我尝试在页面中调用多个对话框时,我遇到了问题。点击3个标签时我有三个锚标签我必须生成具有不同内容的对话框。但是当我点击第二个标签时,我得到的是前一个标签的相同对话框?如何刷新对话框中的内容?

我所做的工作如下:

$("a.delete").click(function (event) {
        DialogBox('#DeleteConfirm');
});

   $("a.message").click(function (event) {
            DialogBox('#DeleteConfirm');
    });

 var $dialog = null; function dialog() {
    // create dialog if not done already
    if (!$dialog) {
        $dialog = $("#dialogToShow").dialog({
            title: "Confirm Password",
            closeText: "Cancel",
            show:"slide",
            resizable: false,
            modal: true,
            autoOpen: false, // this is important! prevent auto open
            open: function(ev, ui){
                $('.ui-widget-overlay').stop().animate({"opacity": "0.40"}, 1480);
            },
            close: function(ev, ui){
                $('.ui-widget-overlay').stop().animate({"opacity": "0"}, 1480);
            }                  
        });
    }
    // use the reference to the dialog and call open.
    $dialog.dialog('open');
    return false; }

有人能帮助我吗?

1 个答案:

答案 0 :(得分:1)

你必须为每个案例创建一个单独的对话框 - 并单独调用它们

如果我理解正确的话,你应该做某事。像

$("a.delete").click(function (event) {
    dialog($('#DeleteDialog'), "Confirm Password");
);

$("a.message").click(function (event) {
        dialog($('#MessageDialog'), "Message");
});

function dialog(content, title) {
     $(content).dialog({
        title: title,
        closeText: "Cancel",
        show:"slide",
        resizable: false,
        modal: true,
        //autoOpen: false, // this is important! prevent auto open
        open: function(ev, ui){
            $('.ui-widget-overlay').stop().animate({"opacity": "0.40"}, 1480);
        },
        close: function(ev, ui){
            $('.ui-widget-overlay').stop().animate({"opacity": "0"}, 1480);
        }                  
    });
}