Nested Fancybox Instances

375 views
Skip to first unread message

saiori

unread,
Mar 12, 2011, 5:29:03 PM3/12/11
to fancybox
Hello Everyone,
I have recently started using jquery and Fancybox and I love them
both. I'm a little lost on how to accomplish something and am hoping
that you will be able to help me. I've searched Google and this site
for hours today and cannot seem to find an answer that works for me.
My situation is this: I have a search result page, on each result
is a link that allows a person to add that result item to a project.
That link opens into my first FB, via iframe. This page looks to see
if a person is logged in, and if so will find all their projects they
already have and list them. If the person is not logged in, I warn
them that their projects will only be saved via cookies and it is not
very reliable. I give them a link to login with, which opens up the
second FB via iframe.
When this FB closes, I would like the original FB to reload so that
it can now use the user's account information to pull up their saved
projects and store new ones. This is where I'm stuck.
I had hoped that there would be someway to get the original FB to
just refresh, something like:

parent.$.fancybox.refresh() or parent.$.fancybox.reload()

It seems that refresh/reload has not been setup with FB in order to
work that way. I then thought that I might use $.get() to go out to
the page, get the new information, and then have it return that
information back to the page. When I do that it seems to fail, and
I'm unsure why.

I have tried this,

parent.$.fancybox("<b>Hello</b>, this should refresh the window to
this text?");
or
$.get('http://beta.lightingdeveloper.com/projects/add_project.php',
{}, function(data) { parent.$.fancybox("blah"); } );

And it does work, but when I try using the actual data, the page
follows some link and just loads forever.

$.get('../projects/add_project.php', {part_number_dk: 'MLEAWT-
A1-0000-0001F6-ND', part_number: 'MLEAWT-A1-0000-0001F6', number:
'XLamp%20ML-E', name_short: 'Cree', wavelength_color_temp: '3750K',
num_leds: '16', lumens: '138.6', current_lumens: '30mA',
voltage_lumens: '2.85', lumens_per_watt: '101.16', price: '$14.24',
type: 'LED'}, function(data) { parent.$.fancybox(data); } );

If someone could please point me in the right direction here, I'd be
very grateful. I'm coming up on a deadline soon and I was really
hoping to use this method.

saiori

unread,
Mar 13, 2011, 12:31:35 PM3/13/11
to fancybox
A friend helped me work out a method for this and thought I would
share just in case someone else runs across this issue.

This is added to the second FB, so that it reloads the first one.
Works in FF 3.6.6, Chrome 10.0, and IE 8 (and 8 compatibility mode).

'onClosed' : function() {
var saveFrame = parent.$("#fancybox-frame");
if (saveFrame.length > 0) {
var domFrame = saveFrame.get(0);
if (typeof(domFrame.contentDocument) != "undefined") {
domFrame.contentDocument.location.reload(true);
}
else if (typeof(domFrame.contentWindow) != "undefined") {
domFrame.contentWindow.location.reload(true);
}
}
}
});
Reply all
Reply to author
Forward
0 new messages