admin管理员组文章数量:1434904
i've searched through the forum yet i can't find the solution. i'm refering to this thread to do the auto close function: ... I did follow JFK's solution which works just right:
'onComplete': function() {
$("#fancybox-wrap, #fancybox-overlay").delay(3000).fadeOut();
}
if you don't want the user to close the box, then add modal=true
The scenario is I would like the user to have the option to close the modal when they click on the [close] button or click anywhere on the overlay. I'm using the latest version of FB and jQuery on Rails.
Here's my script:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#link_post").fancybox({
'autoDimensions':false,
'width':380,
'height':50,
'title':'This message box will automatically close in 10
seconds.',
'titlePosition':'outside',
'onComplete': function() {
jQuery("#fancybox-wrap, #fancybox-
overlay").delay(10000).fadeOut();
}
});
});
</script>
However, when i clicked on the close button, the title and close button will fade away, but the FB's content and overlay are still there! it will only fade away after 10 seconds. So, my question is how to overwrite the 'onComplete' function if user clicks on the close button before it automatically closes?
i've searched through the forum yet i can't find the solution. i'm refering to this thread to do the auto close function: http://groups.google./group/fancybox/browse_thread/thread/d09438b7... I did follow JFK's solution which works just right:
'onComplete': function() {
$("#fancybox-wrap, #fancybox-overlay").delay(3000).fadeOut();
}
if you don't want the user to close the box, then add modal=true
The scenario is I would like the user to have the option to close the modal when they click on the [close] button or click anywhere on the overlay. I'm using the latest version of FB and jQuery on Rails.
Here's my script:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#link_post").fancybox({
'autoDimensions':false,
'width':380,
'height':50,
'title':'This message box will automatically close in 10
seconds.',
'titlePosition':'outside',
'onComplete': function() {
jQuery("#fancybox-wrap, #fancybox-
overlay").delay(10000).fadeOut();
}
});
});
</script>
However, when i clicked on the close button, the title and close button will fade away, but the FB's content and overlay are still there! it will only fade away after 10 seconds. So, my question is how to overwrite the 'onComplete' function if user clicks on the close button before it automatically closes?
Share Improve this question edited Feb 11, 2014 at 20:48 tshepang 12.5k25 gold badges98 silver badges139 bronze badges asked Jun 16, 2010 at 13:38 justinwjustinw 7108 silver badges11 bronze badges2 Answers
Reset to default 2Alright, i've found the solution. FYI, i'm using fancybox v1.3.1 and jQuery v1.4.2
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#link_post").fancybox({
'autoDimensions':false,
'width':380,
'height':50,
'title':'This message box will automatically close in 10
seconds.',
'titlePosition':'outside',
'onComplete': function() {
jQuery("#fancybox-wrap, #fancybox-
overlay").delay(10000).fadeOut();
}
});
jQuery("#fancybox-close").click(function() {
jQuery('#fancybox-overlay').stop();
jQuery('#fancybox-wrap').stop();
});
});
</script>
$(document).ready(function() {
$('.fancybox').fancybox({
'afterLoad': function() {
$(".fancybox-overlay").delay(3000).fadeOut();
}
});
});
It is work! for fancybox v2.x.
本文标签: javascriptFancybox Auto Closebut remain user controlStack Overflow
版权声明:本文标题:javascript - Fancybox Auto Close, but remain user control - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745644650a2668061.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论