Fancybox - passing the variable back to parent when closing the fancybox window

Hi, I was wondering if it is possible to return a variable back from fancybox to the parent when the child is closed?

Any information is greatly appreciated.

Hi,

Phil

EDIT **

function cleanUp(){ var bla = $("#fancybox-frame").contents().find('input[name=pd_id]'); alert(bla.val()); } $("#tree .product a[class!=copy]").fancybox({ 'width' : 770, 'height' : '95%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', 'onCleanup' : cleanUp }); 
+7
source share
2 answers

You can see in fancybox api : onClosed... Will be called once FancyBox is closed

 $('.overlay').fancybox({ onClosed: function() { var bla = $('#targetFrame')[0].contentWindow.targetFunction(); } }); 

There is no child window / iframe, the field is just an absolutely positioned div. It is in the same DOM as the page.

+2
source

In parent I define

 var $_returnvalue = false; 

And onClosed looks like this:

 onClosed: function() { if ($_returnvalue != false) { // Do something in the parent } 

And on the fancybox page, when something is ready to return, I set this value to parent. $ _ returnvalue , and then close the window. This works well for selecting something from a list and passing that value back to the calling page.

+5
source

All Articles