admin管理员组文章数量:1200364
I'm trying to destroy Fancybox. I haven't found any method to do it in documentation. How to destroy it after it was initialized?
This doesn't work:
$("a").unbind('fancybox').unbind('click');
Testing code: /
I use current version 2.1.4.
I'm trying to destroy Fancybox. I haven't found any method to do it in documentation. How to destroy it after it was initialized?
This doesn't work:
$("a").unbind('fancybox').unbind('click');
Testing code: http://jsfiddle.net/martinba/yy3cw/2/
I use current version 2.1.4.
Share Improve this question asked Mar 1, 2013 at 9:34 Martin IlleMartin Ille 7,05510 gold badges46 silver badges65 bronze badges 2- What do you mean by destroy? Do you want to hide these all? – Manoz Commented Mar 1, 2013 at 9:39
- I need it back to standart behaviour: you click on the link <a href="..."> ... </a> and the browser will open it. No Fancybox inner windows, just like there's no javascript. – Martin Ille Commented Mar 1, 2013 at 9:42
4 Answers
Reset to default 15In order to unbind fancybox you have to unbind events under fb-start
namespace from document
:
$(document).unbind('click.fb-start');
Though, I don't know why developer made it so unobvious.
http://jsfiddle.net/dfsq/yy3cw/16/
Try to call:
.unbind('click.fb')
to unbind fancybox.
like:
$('.group').unbind('click.fb')
You can unbind every fancy box by running:
$(document).unbind('click.fb-start');
Or if you need to unbind a specific selector, you can undelegate it:
var selector = 'a.my-fancy-box';
selector = selector + ":not('.fancybox-item, .fancybox-nav')";
$(document).undelegate(selector, 'click.fb-start');
Or alternatively:
// Bind
$('a.my-fancy-box').fancybox({live: false});
// Unbind
$('a.my-fancy-box').unbind('click.fb');
As it was mentioned here earlier: $(document).unbind('click.fb-start');
But you also might want to add this option to the fancybox init call: live:false
本文标签: javascriptHow to destroy FancyboxStack Overflow
版权声明:本文标题:javascript - How to destroy Fancybox? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738527169a2092897.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论