Search code examples
simplemodal

SimpleModal crashing upon call to close modal


I have a div element defined as:

<div id="searchDialog" class="searchDialog">...</div>

In my code, I open the div as a modal dialog using this block of code:

$("#searchDialog").modal({ opacity: 70, 
                           overlayCss: { backgroundColor: "Black" }, 
                           overlayClose: false
                          });

When I attempt to close the dialog with this code:

$.modal.close();

I'm getting a runtime error:

Microsoft JScript runtime error: Unable to get value of the property 'remove': object is null or undefined.

Visual Studio debugger is highlighting the statement "a.d.overlay.remove();" in the SimpleModal javascript source.

I'm using Visual Studio 2010 and the browser is IE 9. The version of SimpleModal is 1.4.

Anyone have any suggestions?

Richard


Solution

  • There is a bug in the SimpleModal library. To fix it on your box, change

    setTimeout(function(){
        // opera work-around
        s.d.overlay.remove();
    
        // reset the dialog object
        s.d = {};
    }, 10);
    

    to

    setTimeout(function(){
        // opera work-around
        if (s.d.overlay){
            s.d.overlay.remove();
        }
    
        // reset the dialog object
        s.d = {};
    }, 10);
    

    See the SimpleModal bug tracker for details.