How to completely remove a dialog on close

前端 未结 7 2130
深忆病人
深忆病人 2020-12-02 05:56

When an ajax operation fails, I create a new div with the errors and then show it as a dialog. When the dialog is closed I would like to completely destroy and remove the di

7条回答
  •  清歌不尽
    2020-12-02 06:35

    Why do you want to remove it?

    If it is to prevent multiple instances being created, then just use the following approach...

    $('#myDialog') 
        .dialog( 
        { 
            title: 'Error', 
            close: function(event, ui) 
            { 
                $(this).dialog('close');
            } 
        }); 
    

    And when the error occurs, you would do...

    $('#myDialog').html("Ooops.");
    $('#myDialog').dialog('open');
    

提交回复
热议问题