关闭Fancybox模式窗口并在提交登录表单后重新加载页面 [英] Close Fancybox modal window and reload the page after login form has been submitted
问题描述
我在FancyBox 2模态iframe窗口中打开了一个登录表单。但是当你提交表格时,网页就会在模态中打开。
I've got a login form opening in a FancyBox 2 modal iframe window. But when you submit the form, the web page is opening within the modal.
任何人都可以告诉我是否以及如何使Fancybox模式关闭,以及基础页面是否重要在提交登录表单时加载吗?
Can anyone tell me if and how to make the Fancybox modal close, and the underlying page re-load when the login form is submitted please?
这是我当前的代码 - 在functions.js文件中:
Here's my current code - within a functions.js file:
$(".login-popup").fancybox({
maxWidth : 310,
height : 300,
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none'
});
这是我的登录链接:
<a class="login-popup" data-fancybox-type="iframe" href="/popup/login" title="">Login</a>
感谢您的帮助,
Ste
编辑1:
感谢您的帮助。很抱歉成为一个完整的新手,但我遇到了父母的问题。$。fancybox.close();处理表单submit()事件。这是我现在正在使用的代码,但它并没有关闭窗口,因为我做错了。有什么想法吗?谢谢。
Thanks for the help with this. Sorry for being a complete newbie, but I'm having trouble getting the parent.$.fancybox.close(); to work on the form submit() event. Here's the code I'm now using but it doens't close the window as I'm doing something wrong. Any ideas what? Thanks.
$(".login-popup").fancybox({
closeEffect : 'none',
'afterClose':function () {
window.location.reload();
},
});
$(".login-form").submit(function(){
parent.fancyBoxClose();
});
推荐答案
要从iframe中关闭fancybox,你可以在表单上使用
parent。$。fancybox.close();
submit()
event。
To close the fancybox from within the iframe, you can use parent.$.fancybox.close();
on the form
submit()
event.
然后在Fancybox初始化程序中添加一个onClose事件,该事件将重新加载页面:
Then add an onClose event on the Fancybox initializer, which would reload the page:
$(".login-popup").fancybox({
maxWidth : 310,
height : 300,
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
'afterClose':function () {
window.location.reload();
},
});
这篇关于关闭Fancybox模式窗口并在提交登录表单后重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!