关闭 fancybox 窗口:适用于 iframe 但不适用于 ajax
我有一个工作 fancybox 模态窗口,其中包含下一个代码:
$("a#add-project").click(function(){
$.fancybox({
type: 'ajax',
href: BASEPATH + 'time/addProject',
fitToView: false,
autoSize: false,
width: 500,
height: 300,
closeClick: false,
openEffect: 'none',
closeEffect: 'none',
beforeClose: function() {
console.log('closed');
}
});
});
AJAX 窗口包含一个带有下一个代码的按钮:
$('#addproject-close').bind("click keypress", function(){
$.fancybox.close(true);
$.fancybox.close();
parent.$.fancybox.close(true);
parent.$.fancybox.close();
console.log('tried to close');
});
我知道它可以工作,因为我在控制台上看到 尝试关闭 消息,但没有办法关闭该窗口。我尝试了所有可能的事情,但一无所获。过去,我有一个类型为“iframe”且带有parent.$...的窗口。
我怎样才能在ajax中做到这一点?
先感谢您
I have a working fancybox modal window with the next code:
$("a#add-project").click(function(){
$.fancybox({
type: 'ajax',
href: BASEPATH + 'time/addProject',
fitToView: false,
autoSize: false,
width: 500,
height: 300,
closeClick: false,
openEffect: 'none',
closeEffect: 'none',
beforeClose: function() {
console.log('closed');
}
});
});
That AJAX window contains a button with the next code:
$('#addproject-close').bind("click keypress", function(){
$.fancybox.close(true);
$.fancybox.close();
parent.$.fancybox.close(true);
parent.$.fancybox.close();
console.log('tried to close');
});
I know that it works because I see the tried to close message on console but there is NO way to close that window. I tried with all the possible things but nothing. In the past I had this window with type: 'iframe' and with parent.$... just worked.
How I can do it in ajax?
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 AJAX 窗口中,像这样创建关闭按钮:
... 并忘记
.bind()
方法。那应该可以解决问题。 查看演示
Inside your AJAX window, create your closing button like this:
... and forget about the
.bind()
method.That should do the trick. See demo