Fancybox afterClose事件无效 [英] Fancybox afterClose event not working
问题描述
我在关闭后使用fancybox API时遇到问题。
I'm having a problem using the fancybox API after Close.
我在人们点击此功能时打开该功能:
I open the function when people click on this:
<a class="fancybox fancybox.iframe btn" href="myurl.php"></a>
这背后的javascript是:
The javascript behind this is:
$('.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:
基于你的html
<a class="fancybox fancybox.iframe btn" href="myurl.php"></a>
-
使用
afterClose后
回调(不是事件
)而不是beforeClose
。如需进一步参考,请查看提示&技巧 => No.11
Use the
afterClose
callback (not anevent
) instead ofbeforeClose
. For further reference check Tips & Tricks => No.11
类 fancybox
用于将选择器绑定到fancybox,因此初始化代码应如下所示
The class fancybox
is used to bind the selector to fancybox so your initialization code should look like this
jQuery(document).ready(function ($) {
$('.fancybox').fancybox({
arrows: false,
padding: 0,
helpers: {
overlay: {
locked: false
}
},
afterClose: function () {
location.reload();
}
});
}); // ready
(有效) fancybox.iframe
class 告诉fancybox它应该处理的内容类型,但是你不用它来将选择器绑定到fancybox。
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.
参见 JSFIDDLE
See JSFIDDLE
注意:这是针对fancybox v2.x
NOTE : this is for fancybox v2.x
这篇关于Fancybox afterClose事件无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!