JQuery UI多个对话框问题

JQuery UI多个对话框问题

问题描述:

我有动态创建Dialog的功能。有时我需要Modal或确认对话

I have functionality where I dynamically create Dialog. Some time I require Modal or Confirm Dialog

所以我创建了函数

function createDialogWithOutClose()
{
    jQuery('#divPopup').dialog('destroy');

    var dialog = jQuery('#divPopup').dialog({
        autoOpen: false,
        height: 450,
        width: 650,
        modal: true,
        open: function(event, ui){
            jQuery('body').css('overflow','hidden');
        }

    });

    jQuery('#divPopup').dialog('open');
}

function createConfirmDialog(url,params)
{
    jQuery('#divPopup').dialog('destroy');

    var dialog = jQuery('#divPopup').dialog({
        autoOpen: false,
        resizable: false,
        modal: true,
        show: "blind",
        hide: "explode",
        open: function(event, ui){
            jQuery('body').css('overflow','hidden');
        },
        buttons: {
            Ok: function() {
                jQuery( this ).dialog( "close" );
                jQuery.ajax({
                    type: "POST",
                    url: url,
                    data: params
                });
            },
            Cancel: function() {
                jQuery( this ).dialog( "close" );
            }
        }

    });

    jQuery('#divPopup').dialog('open');

}

这里的问题是当我给这个函数打电话时,它打开之前打开的Dialog。

Problem here is when I give call to this function, It opens previously opened Dialog.

我想之前的实例没有被删除。它不会动态创建Dialog

I guess previous instance is not get removed.It doesnt dynamically create Dialog

任何解决方案??