Search code examples
javascriptjqueryjquery-uimodal-dialogjquery-ui-dialog

jQuery UI Dialog Box - does not open after being closed


I have a problem with the jquery-ui dialog box.

The problem is that when I close the dialog box and then I click on the link that triggers it, it does not pop-up again unless I refresh the page.

How can I call the dialog box back without refreshing the actual page.

Below is my code:

$(document).ready(function() {
    $('#showTerms').click(function()
    {
        $('#terms').css('display','inline');
        $('#terms').dialog({
            resizable: false,
            modal: true,
            width: 400,
            height: 450,
            overlay: { backgroundColor: "#000", opacity: 0.5 },
            buttons:{ "Close": function() { $(this).dialog("close"); } },
            close: function(ev, ui) { $(this).remove(); },
    }); 
});

Thanks


Solution

  • I solved it.

    I used destroy instead close function (it doesn't make any sense), but it worked.

    $(document).ready(function() {
    $('#showTerms').click(function()
    {
        $('#terms').css('display','inline');
        $('#terms').dialog({resizable: false,
            modal: true,
            width: 400,
            height: 450,
            overlay: { backgroundColor: "#000", opacity: 0.5 },
            buttons:{ "Close": function() { $(this).dialog('**destroy**'); } },
            close: function(ev, ui) { $(this).close(); },
        });         
    });   
    $('#form1 input#calendarTEST').datepicker({ dateFormat: 'MM d, yy' });
    });