fancybox resize - 如何/何时调用该函数
我有一个精美的盒子,里面有一张表格。如果表单提交不正确,则表单上会出现错误,这会导致内容的高度大于 iframe,并且出现滚动条。
我想要的是在出现错误(div.errors)时调整 fancybox 的大小。
我已经尝试过 $.fancybox.resize 方法,但似乎没有发生任何事情,但很有可能我只是做错了。这是我如何称呼 fancybox 的,
$("#login").fancybox({
'width': 682,
'height': 295,
'autoDimensions': true,
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'iframe'
});
我自己修复了它,但我不喜欢这个解决方案,我至少想让调整大小方法起作用,看看它是否有我想要的结果。这是我必须暂时修复的代码
function resizeFancybox() {
$('#fancybox-inner', top.document).height(500);
$('#fancybox-wrap', top.document).height(500);
$('iframe#fancybox-frame', top.document).css('height', '95%');
parent.$.fancybox.center();
}
if ($(".secure-login .errors").length){
resizeFancybox();
}
谢谢大家
I have a fancybox with a form inside. If the form is incorrectly submitted, then errors appear on the form, which causes the height of the content to be bigger than the iframe, and I get scrollbars.
What I want is to resize the fancybox if there are errors (div.errors).
I have tried the $.fancybox.resize method but nothing seems to happen, but there is a good chance I'm just doing it wrong. Here is how I call the fancybox
$("#login").fancybox({
'width': 682,
'height': 295,
'autoDimensions': true,
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'iframe'
});
I have sort of fixed it myself but I don't like the solution, I'd at least like to get the resize method working to see if it has the outcome I want. Here is the code I have to temporaily fix it
function resizeFancybox() {
$('#fancybox-inner', top.document).height(500);
$('#fancybox-wrap', top.document).height(500);
$('iframe#fancybox-frame', top.document).css('height', '95%');
parent.$.fancybox.center();
}
if ($(".secure-login .errors").length){
resizeFancybox();
}
Thanks all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题解决了吗?我只是无意中自己找到了解决方案,如果有人遇到与我相同的问题,请分享,我花了半天时间才弄清楚。
Is your problem solved? I just accidentally found out solution myself, just share if anyone come across the same problem as mine which took me half of day to figure it out.