javascript Fancybox - 实现 afterClose 回调
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15646822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fancybox - Implementing afterClose callback
提问by Dave Bar
My javascript syntax is rookie-level, but I'm learning :>
我的 javascript 语法是菜鸟级的,但我正在学习 :>
I'm using Fancybox 2.1.4 to reveal an inline <div id="content">
.
Traditionally, the <div>
would be set to style="display:none"
and Fancybox will change that to block when activated, and back to none
when closed.
我正在使用 Fancybox 2.1.4 来显示内联<div id="content">
. 传统上,<div>
将被设置为style="display:none"
并且 Fancybox 将在激活时将其更改为阻止,并none
在关闭时返回。
In my case, I actually have the content of that <div>
visible on the page in a different location (it's the right thing for the project, I know there are various opinions that can be had there).
就我而言,我实际上<div>
在不同位置的页面上看到了该内容(这对项目来说是正确的,我知道那里可以有各种意见)。
So I need to keep <div id="content">
from disappearing after closing the fancybox (which it natively disappears).
所以我需要<div id="content">
在关闭fancybox(它本机消失)后避免消失。
After some research, I found that using the afterClose
callback, I can simply change or add the inline style of id"content"
to display:block
(which solves the problem.
经过一番研究,我发现使用afterClose
回调,我可以简单地更改或添加id"content"
to的内联样式display:block
(解决了问题。
The problem... is my rookiness :> I tried for quite a long time and just not sure where to put the code, and the right syntax.
问题...是我的菜鸟:> 我尝试了很长时间,只是不确定将代码放在哪里,以及正确的语法。
How would i add that afterClose
to my fancybox function?
我如何将它添加afterClose
到我的fancybox 函数中?
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox(
);
});
</script>
Thanks very much for any assist
非常感谢任何帮助
回答by JFK
This is the format :
这是格式:
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox({
afterClose : function(){
// here any javascript or jQuery to execute after close
}
}); // close fancybox
}); // close ready
</script>