close fancy box from function from within open 'fancybox'

Phil Jackson picture Phil Jackson · Dec 1, 2009 · Viewed 206.9k times · Source

Hi all i want to be able to close fancyBox when it is open from within.

I have tried the following but to no avail:

function closeFancyBox(html){
    var re = /.*Element insert complete!.*/gi;
    if( html.search( re ) == 0 ){
        $.fancybox.close();
        //alert("foo");
    }
}

foo will open in dialog but will not close down. any hints?

Answer

Matt Furlong picture Matt Furlong · Jun 25, 2010

Try this: parent.$.fancybox.close();

See Fancybox API documentation.