最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery UI Multiple Dialog Issue - Stack Overflow

programmeradmin1浏览0评论

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

So I created to Function

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');
}

and

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');

}

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

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

Any solution??

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

So I created to Function

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');
}

and

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');

}

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

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

Any solution??

Share Improve this question asked Jan 14, 2012 at 11:17 AliManAliMan 1072 gold badges2 silver badges10 bronze badges 1
  • possible duplicate of jquery: How to pletely remove a dialog on close – mplungjan Commented Jan 14, 2012 at 11:59
Add a ment  | 

2 Answers 2

Reset to default 4

Have a look at http://docs.jquery./UI/Dialog/dialog#method-destroy

jquery: How to pletely remove a dialog on close

http://groups.google./group/jquery-ui/browse_thread/thread/4f9804ccb01c1bc8/5b1971d1f0abf1fa?pli=1

Simply use a flag to check dialog state (close/open)

var Open = false;
$('button').click(function () {
    if (!Open) {
        Open = true;
        $(newDiv).dialog({
            close: function (event, ui) {
                Open = false;
            }
        });

    } else {
        alert("Close opened dialog first");
    }
});
发布评论

评论列表(0)

  1. 暂无评论