我正在使用FancyBox (版本2),在FancyBox中包含一个联系表单。我正在添加自己的“您确定要关闭吗?”窗口而不是基本的
但是它在显示 div 后立即关闭。如何取消 fancyBox 的关闭,除非单击"Yes"按钮?
确认 div 的 HTML:
我试过在
confirm()
,以便如果用户意外点击关闭,表单内容不会丢失。这是我所做的:$('.fancybox').fancybox({
openEffect: 'fade',
closeEffect: 'fade',
openSpeed: 'fast',
closeSpeed: 'fast',
beforeClose: function() { $('#confirm_contact_close').fadeIn(300); }
});
但是它在显示 div 后立即关闭。如何取消 fancyBox 的关闭,除非单击"Yes"按钮?
确认 div 的 HTML:
<div id="confirm_contact_close">
<h2 class="secondary_heading" style="font-size: 27px;">Do you really want to continue?</h1>
<p>If you continue, the entire form will be cleared.</p>
<br />
<button id="continue_contact_close">Yes</button>
<button id="cancel_contact_close">No</button>
</div>
按钮的jQuery:
$('#confirm_contact_close').fadeIn(300);
$('#continue_contact_close').live('click', function() {
$.fancybox.close(true);
});
$('#cancel_contact_close').live('click',function() {
$('#confirm_contact_close').fadeOut(300);
});
我试过在
beforeClose
回调中添加 return false;
,但这并不起作用,因为当单击 "是" 按钮时,它也不会关闭。感谢您的理解。