Timigen
Timigen

Reputation: 1025

buttons persist when launching dialog

I am using jQueryUI and I have a web page with a few links that when clicked will display a modal window. The issue i am having is that when i click one of the links that has a button then close it and click another link that doesnt have buttons the modal launches but the buttons are still there. Despite the fact that no buttons are being specified. I have tried to use the close property when creating the dialog calling $(this).dialog("close") doesnt solve the issue. Calling $(this).dialog("destroy") solves the issue except that the contents of the modal are then shown on the webpage.

This is the function I call to launch the modal.

General.modal = function(options)
{   
    if(!options.hasOwnProperty(modal))
{
    options.modal = true;
}

$('#modal').dialog(options);
};

This is the call without buttons.

myApp.General.modal({
    title : groupTitle + " Documentation",
    height : 500, 
    width : 600, 
});

This is the call to that function with buttons:

myApp.General.modal({
    title : "Upload Documentation (" + groupTitle + ")",
    height : 500,
    close: function(){$(this).dialog("close");},
    width : 600, 
    buttons : {
        "Upload" : jQuery.proxy(directoryView.uploadClicked, directoryView, model.get("gid"))
    }
});

Upvotes: 2

Views: 49

Answers (1)

joeldixon66
joeldixon66

Reputation: 950

I presume that the dialog is not being destroyed so the last button definition is staying around. You probably need to ensure the buttons attribute is null on subsequent calls:

myApp.General.modal({
    title : groupTitle + " Documentation",
    height : 500, 
    width : 600, 
    buttons : null,
});

Upvotes: 2

Related Questions