Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FancyBox custom close button

I want to set up buttons types that can close the window, so I made wrote this code:

$(".fstandard").fancybox({
    afterClose: function() {
        alert("Closed!");
    },
    afterShow : function() {
        $(':button').click(function() {
            $.fancybox.close();
        })
    }
});

I tried in vain several other codes, but none of them worked, the window does not close. This line gives me an error:

$.fancybox.close(); 

$.fancybox is undefined

I use FancyBox v2.0.3. In their documentation, it is well presented to close the window: http://fancyapps.com/fancybox/#support

Thanks in advance

like image 813
Roukmoute Avatar asked Dec 07 '22 17:12

Roukmoute


1 Answers

It says in the documentation:

To use from inside the iframe - <a href="javascript:parent.$.fancybox.close();">Close me</a>

Have you tried:

$(':button').click(function() {
    parent.$.fancybox.close();
})
like image 189
Rory McCrossan Avatar answered Dec 10 '22 13:12

Rory McCrossan