关于SimpleModal jQuery插件的问题 - 初次打开后可能重新居中? [英] Question about SimpleModal jQuery plugin -- possible to re-center after initial open?

查看:93
本文介绍了关于SimpleModal jQuery插件的问题 - 初次打开后可能重新居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与 SimpleModal jQuery插件有关。我打开模态窗口没有问题,但一旦打开它就会停留在屏幕上[居中]的位置,但是它的内容正在变化,使其更高,因此不再居中。是否有一种简单的方法可以重新调整它以使其再次居中?

my problem has to do with the SimpleModal jQuery plugin. I have no problem opening the modal window, but once it opens it stays where it is [centered] on the screen, however its contents are changing, making it taller and therefore no longer centered. Is there a simple way to realign it so it becomes centered again?

编辑:我认为通过显示两个来解释我的问题会有所帮助截图:之前& 之后 - 基本上我使用的是jQuery的 slideUp & slideDown 功能隐藏信用卡表单,具体取决于用户是通过现金/支票还是信用卡付款卡。很明显,在信用卡字段中,容器的高度会增加。

I think it would help to explain my problem by showing two screenshots: before & after -- basically I am using jQuery's slideUp & slideDown functionality to hide the credit card form depending on whether the user is paying via cash/cheque or credit card. Obviously with the credit card fields the height of the container is increased.

我尝试添加 $(div#modal-element)。setPosition ()在slideUp / slideDown的回调元素中但无效 - 事实上 setPosition()抛出一个JS错误,因为显然是函数不存在。我总是尝试添加autoResize选项并将其设置为true。

I tried adding $("div#modal-element").setPosition() in a callback element of slideUp/slideDown but to no avail -- in fact setPosition() is throwing a JS error because apparently the function doesn't exist. I always tried adding the autoResize option and setting it to true.

推荐答案

由于SimpleModal被操纵以处理窗口的重新定心调整大小,最简单的方法是触发该事件。内容更改后,只需调用:

Since the SimpleModal is rigged to handle re-centering on window resize, the simplest method would be to trigger that event. After your content changes, just call this:

$(window).resize();

这篇关于关于SimpleModal jQuery插件的问题 - 初次打开后可能重新居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆