javascript 如何正确使用 Fancybox 的 onClose 属性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9694131/
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
How do I correctly use Fancybox's onClose property?
提问by jmealy
I'm trying to update the shopping cart of my site upon closing a Fancybox instance. I'm using Fancybox 1.3.4. Assuming my function is valid, shouldn't the following work?
我正在尝试在关闭 Fancybox 实例后更新我网站的购物车。我正在使用 Fancybox 1.3.4。假设我的函数有效,以下不应该工作吗?
<script type="text/javascript">
$(function () {
$("a.ProductRollover").fancybox({
'padding':0,
'width': 785,
'height': 554,
'autoScale': false,
'type': 'iframe',
'onClosed': function() {
$('#cart_total').html(json['total']);
}
});
});
</script>
Thank you.
谢谢你。
采纳答案by Ali
Instead of using onClosed use beforeClose or afterClose. Find the API documentation under the Callbacks tab here http://fancyapps.com/fancybox/#docs.
而不是使用 onClosed 使用 beforeClose 或 afterClose。在此处http://fancyapps.com/fancybox/#docs的回调选项卡下找到 API 文档。
Moreover, answer by Mottieover here Load new content in Fancybox on Fancybox onClosed eventmight be helpful.
此外,Mottie在此处的回答在 Fancybox onClosed 事件上加载 Fancybox 中的新内容可能会有所帮助。