Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bind a jquery function to fancybox .close() event

I would like to trigger a simple jQuery function based on a fancybox closing. it is the only fancybox on the page

$.fn.fancybox.close = function() {     $('#sub_cont').hide(250, function() {     $('#IDsearchform input').val('');     });  }); 

ofcourse the above doesn't work

like image 728
Jeff Voss Avatar asked Apr 22 '11 01:04

Jeff Voss


People also ask

How do I close a fancybox after submitting?

You can close it with $. fancybox. close() .

What is Fancybox jQuery?

FancyBox is a tool for displaying images, html content and multi-media in a Mac-style "lightbox" that floats overtop of web page. It was built using the jQuery library. Licensed under both MIT and GPL licenses.


1 Answers

*Update: * Please take a note of @mathoiland's answer, "It looks like Fancybox 2 deprecated the onClosed callback. It now uses afterClose." if you are using FancyBox 2.x

Pass the onClosed option to the fancybox function.

i.e:

$("<YOUR-SELECTOR>").fancybox({   onClosed: function() {     $('#sub_cont').hide(250, function() {     $('#IDsearchform input').val('');     });   }) }); 
like image 88
Chandu Avatar answered Sep 17 '22 15:09

Chandu