Is there a way to run a function on Fancybox open and close?
I want to run a small function as the Fancybox trigger is fired, and when the Fancybox window is closed.
Here is the code: if ($('div#fancybox-frame:empty'). length >0) { alert('it is empty'); $.
Fancybox has some callbacks for that so if running v1.3.4 you could do
$(".fancybox").fancybox({
   "onComplete": function(){
      // fancybox is open, run myFunct()
   },
   "onClosed": function(){
      // fancybox is closed, run myOtherFunct()
   }
});
for v2.1.x
$(".fancybox").fancybox({
   afterShow: function(){
      // fancybox is open, run myFunct()
   },
   afterClose: function(){
      // fancybox is closed, run myOtherFunct()
   }
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With