从Fancybox打开Fancybox并关闭父级 [英] Open Fancybox from Fancybox and close parent
问题描述
我遇到了化装箱麻烦.我的产品正在fancybox中打开,我有相关的产品含锡.当用户单击相关链接并在新的fancybox中打开产品时,我想关闭fancybox.
I have fancybox trouble. My product is opening in fancybox and I have related products withtin content. I would like to close fancybox when user clicks on related link and open product in new fancybox.
谢谢你们的帮助.但这不起作用:(..产品会在没有fancybox的窗口中打开.
Thank you guys for your help. But it is not working :( . Product opens in a window without 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'
});
$("a#fancy2").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'autoDimensions' : false,
'width' : 620,
'height' : 'auto',
'overlayShow' : true,
'overlayOpacity' : 0.8,
'overlayColor' : '#ccc'
});
});
这就是我所拥有的.单击产品将打开fancybox"fancy1".但是单击fancybox链接中的链接会打开相关产品而没有花哨,我得到:
This what I have. Clicking on the product opens fancybox "fancy1". But Clicking within fancybox link opens related product without fancy and I'm getting:
( $未定义$(function(){$('#form_2538').validate();}); )!
以这种方式链接到产品
<a id="fancy1" href="product_url" >
通过这种方式链接到相关内容
Linking to a related done this way
<a id="fancy2" href="product_url" >
我一直为此苦苦挣扎:(
I have been struggling with this for a while :(
我已经解决了它!!!!!!!!!
AND I HAVE RESOLVED IT!!!!!!!!!!!!!!!!!!!
我已经解决了问题!
请参见下文!
$(document).ready(function() {
$("a.fancy1").live("hover",
function()
{$("a.fancy1").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'autoDimensions' : false,
'width' : 620,
'height' : 'auto',
'overlayShow' : true,
'overlayOpacity' : 0.8,
'overlayColor' : '#ccc'
});
});
});
推荐答案
您必须像每个链接一样分别为每个链接绑定fancybox
You have to bind fancybox for each link separately like
$("a#fancy1").fancybox({
// options
});
$("a#fancy2").fancybox({
// options
});
请注意,第二个脚本不在第一个脚本的内部(onClosed
选项).
Notice that the second script is not inside of the first one (onClosed
option).
打开第一个fancybox,例如:
Open the first fancybox like:
<a id="fancy1" href="{link to product}">open product</a>
然后在打开的内容中,您应该有一个类似的链接
Then inside the opened content you should have a link like
<a id="fancy2" href="{target to related product}">see related product</a>
您实际上不必关闭第一个fancybox,从其内部链接到第二个fancybox即可将其关闭.
you don't actually have to close the first fancybox, linking to the second from inside of it will close it.
这篇关于从Fancybox打开Fancybox并关闭父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!