Link to home
Start Free TrialLog in
Avatar of ericdalrymple
ericdalrymple

asked on

jquery modal dialog overlay keeps getting darker on subsequent dialog.load

I have a jquery modal dialog that I use to display the details from a list page when the user clicks on a row in the list. Everything works fine except for this. Each time the dialog is opened and closed, the background of the list page gets darker and darker... eventually black.

Am I not closing the dialog properly?
strTitle="Item Details";
$("#detailsModal").dialog({
    autoOpen:"true",
    overlay: {
        "background-color": "#000",
        "opacity": "0.50",
        "-moz-opacity": "0.50"
    },
    autoOpen:"true",
    title:"Item Details,
    resizable:"true",
    modal:"true",
    height:500,
    width:700});
    
    $("#detailsModal").load("http://myurl?itemId=105");
}
 
 
Here is how I close the dialog:
<input type=button value=CANCEL onclick="$('#detailsModal').empty().dialog('close');">

Open in new window

Avatar of ericdalrymple
ericdalrymple

ASKER

I'm sure there is a better way... but here is how I got around it...when I click the cancel button I added a remove() which gets rid of the dialog div
echo"<input type=button value=CANCEL onclick=\"$('#detailsModal').dialog('close').remove();createDiv('detailsModal');\">&nbsp;";

here is the function to create the new div....
    function createDiv(strDiv){
       var newdiv = document.createElement('div');
       newdiv.style.width = 935;
       newdiv.style.height = 570;
       newdiv.innerHTML ="&nbsp;";
       newdiv.style.className = "flora";
       newdiv.style.position = "absolute";
       document.body.appendChild(newdiv);
       newdiv.setAttribute('id',strDiv);
    }
nevermind... still have problems... will update this later
ASKER CERTIFIED SOLUTION
Avatar of anoyes
anoyes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial