jQuery UI - 对话框 - 高度
我有一个正在创建的 jQuery UI 对话框。它一开始是一个空 div,然后我通过绑定到对话框的打开事件的 Ajax 调用来填充它。
现在,我的问题是,当对话框第一次显示时,没有内容,因此它的高度非常小。当 Ajax 请求完成时,这会导致对话框向下推,离开屏幕。但是,随后单击打开对话框会导致其正确重新定位 - 也许在初始调整大小后更新了高度以供将来使用?
我的问题是,是否有一个事件可以在对话框上触发,使其在 Ajax 请求完成后重新定位?我浏览了文档,但找不到任何内容。我现在正在查看 UIDialog 的源文件,但我想我会在阅读时在这里问。
编辑:这是一个小提琴。请务必在打开函数内设置 height
变量,然后单击、关闭并重新单击。
I have a jQuery UI Dialog box, that I'm creating. It starts out as an empty div that I then populate via an Ajax call that is bound to the dialog's open event.
Now, my issue is that when the dialog is first displayed, there is no content, so its height is very small. This causes the dialog to push downwards, off screen when the Ajax request completes. However, subsequent clicks to open the Dialog cause it to be repositioned correctly - perhaps the height is updated for future use after the initial resize?
My question is, is there an event I can trigger on the dialog to cause it to reposition itself after the Ajax request completes? I've browsed the documentation, but can't find anything. I'm in the middle of looking through the source file right now for UIDialog, but figured I'd ask here while I'm reading.
EDIT: Here is a fiddle. Be sure to set the height
variable inside of the open function, then click, close, and re-click.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,只需重置对话框的位置就足够了:
http://jsfiddle.net/P9X9v/1/
将其添加到打开事件函数中可以修复此问题:
$(this).dialog("option", "position", "center");
It turns out just resetting the dialog's position was enough:
http://jsfiddle.net/P9X9v/1/
Adding this to the open event function fixes it:
$(this).dialog("option", "position", "center");