[英]Fancybox afterClose event not working
I'm having a problem using the fancybox API after Close. 关闭后使用fancybox API时遇到问题。
I open the function when people click on this: 当人们单击此按钮时,我打开该功能:
<a class="fancybox fancybox.iframe btn" href="myurl.php"></a>
The javascript behind this is: 这背后的JavaScript是:
$('.fancybox.iframe')
.fancybox({
arrows: false,
padding: 0,
overlay: {
locked: false
},
beforeClose: function () {
location.reload();
}
});
And it never reload the page when I close it. 当我关闭它时,它永远不会重新加载页面。 Can somebody help me?
有人可以帮我吗? Thank you !
谢谢 !
Some clarification to avoid further confusion: 为了避免进一步的混淆,需要进行一些澄清:
Based on your html 根据您的html
<a class="fancybox fancybox.iframe btn" href="myurl.php"></a>
Use the afterClose
callback (not an event
) instead of beforeClose
. 使用
afterClose
回调(不是event
)而不是beforeClose
。 For further reference check Tips & Tricks => No.11 有关更多参考,请参见技巧和窍门 => No.11
The class fancybox
is used to bind the selector to fancybox so your initialization code should look like this fancybox
类用于将选择器绑定到fancybox,因此您的初始化代码应如下所示
jQuery(document).ready(function ($) { $('.fancybox').fancybox({ arrows: false, padding: 0, helpers: { overlay: { locked: false } }, afterClose: function () { location.reload(); } }); }); // ready
The (valid) fancybox.iframe
class tells fancybox the type of content it should handle, but you don't use it to bind the selector to fancybox. (有效的)
fancybox.iframe
类告诉fancybox它应该处理的内容类型,但是您不使用它将选择器绑定到fancybox。
NOTE : this is for fancybox v2.x 注意 :这是为fancybox v2.x
You should use 你应该用
$('.fancybox.iframe').fancybox({
arrows: false,
padding: 0,
helpers: { overlay : {closeClick: false} },
beforeClose: function () {
parent.location.reload(true);
}
});
(Note that the syntax is different between version 1 and 2 of fancybox. The above is for fancybox2) (请注意,fancybox的版本1和版本2的语法不同。以上适用于fancybox2)
Try using onClose
event: 尝试使用
onClose
事件:
$('.fancybox.iframe')
.fancybox({
arrows : false,
padding: 0,
overlay: {
locked: false
},
onClosed: function() {
location.reload();
}
});
According to the API there is no beforeClose
event, but there is onClose
根据API,没有
beforeClose
事件,但是有onClose
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.