Open Fancybox from link in Fancybox

61 views
Skip to first unread message

Hercules

unread,
May 25, 2012, 1:48:50 PM5/25/12
to fancybox
Dear All,

I have small issue with calling fancybox. To make story short:

I have a product page which opens in fancybox. Within this page I have
a link for related products. Clicking on it closes fancybox and opens
related product in fancybox. As you already guessed product page which
will open also has related products., so clicking on related product
doesn't open fancybox. I was wondering if you could help me in
resolving this issue.

Here is my code:

Link to product: <a href="blabla" id="fancy1">Product</a> Works,
opens in fancybox.

Link within product page (related product): <a href="blabla"
id="fancy1">Product</a> Works, opens in fancybox.

Link within opened related product page: <a href="blabla"
id="fancy1">Product</a> Doesn't open in Fancybox.

$(document).ready(function() {



$("a.fancy1").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'autoDimensions' : false,
'width' : 620,
'height' : 'auto',
'overlayShow' : true,
'overlayOpacity' : 0.8,
'overlayColor' : '#ccc',
onComplete: function() {
$("a.fancy1").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'autoDimensions' : false,
'width' : 620,
'height' : 'auto',
'overlayShow' : true,
'overlayOpacity' : 0.8,
'overlayColor' : '#ccc'
});


}
});
});

I have tried naming fancy2 for related products and nothing works.

JFK

unread,
May 25, 2012, 1:53:36 PM5/25/12
to fancybox
if your script is a class, your link should be too
<a href="blabla" class="fancy1">Product</a>

you don't need $("a.fancy1").fancybox() twice
I already answered to you at stackoverflow

Hercules

unread,
May 25, 2012, 1:58:46 PM5/25/12
to fancybox
Sorry tipo... because I was trying classes and id's. Links are NOT
id's (typo) they are classes.

Do you have some kind of example of what I'm trying to accomplish?

Hercules

unread,
May 25, 2012, 3:16:20 PM5/25/12
to fancybox
I made it work better than you suggested!

Look on Stackoverflow!

JFK

unread,
May 25, 2012, 7:33:47 PM5/25/12
to fancybox
I bet you did, because you knew what you were doing but we didn't (you
didn't provide enough information nor a link)
your solution makes me think that the link inside fancybox didn't
exist in the DOM but it was added dynamically
it also makes me think that you are using fancybox v1.3.4, which
doesn't support dynamically added elements

I also see that you used a jQuery deprecated function, which doesn't
make it any better.
anyway, glad to hear you solved your issue
Reply all
Reply to author
Forward
0 new messages