Reputation: 1606
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.
Upvotes: 5
Views: 21459
Reputation: 41143
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()
}
});
Upvotes: 23