Reputation: 473
I have an application where I am using Fancyboxes to display content from the server through IFRAMES within the Fancyboxes. So, I am looking to run a script after data is submitted or changed in the server that calls the current fancybox with IFRAME to close and open another fancybox with a new url, size, and iframe inside of it.
I have tried several different codes through various googled sites, but none have worked for my app.
Help would be greatly appreciated!
UPDATE: Found the answer here: http://www.amitpatil.me/fancybox-runtime-resizing-of-iframe/
Upvotes: 2
Views: 3574
Reputation: 2530
The method suggested by @TamasPap didn't work for me, and since I'd spent hours researching and experimenting until I finally found a method which worked, I wanted to share it.
parent.$.fancybox.open({ href : 'iframe2.html', type: 'iframe'});
parent.$.fancybox.close({ href : 'iframe1.html'});
You can specify any options, helpers or css after type: 'iframe' in the same manner you would when creating the function.
Upvotes: 0
Reputation: 18273
Call $.fancybox.close
or parent.$.fancybox.close()
(from iframe), and open a new one:
$.fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'width' : 680,
'height' : 495,
'href' : 'http://example.com/new'
});
or simply resize fancybox: $.fancybox.resize(). This will help you in resizing: How do you resize Fancybox at runtime?
[UPDATE]
As I understand: You have A.php opened with fancybox. On A.php you probably have a form, and the form is submitted to B.php. If this is the situation, you have to close+open OR just resize the fancybox in the document.ready of B.php by parent.$.fancybox.function_name.
Upvotes: 1
Reputation: 13630
Don't know if you've tried this, but seems to work for me:
parent.MyFunction(); // call this from the iframed url
function MyFunction(){ // have this in your parent page
// call your fancybox close function here
}
Upvotes: 0