JQuery UI对话框可以记住它在打开和关闭之间的位置 [英] Can JQuery UI Dialog remember its position between opening and closing

查看:178
本文介绍了JQuery UI对话框可以记住它在打开和关闭之间的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我动态打开和关闭的JQuery对话框。一切都正常,除了对话框的位置在关闭然后重新打开后不会被记住。



大小保持不变,但位置不是。



我已经尝试挂入打开事件,但是在我手动重新定位元素后,似乎该位置正被JQuery UI重置。



是否保持对话框的大小可能?我确实认为应该是。

解决方案

您可以使用jQuery UI对话框beforeclose事件来存储位置和大小。您可以使用选项方法设置位置和大小。



以下是目前适用于我的:



< $ {
$ b $($)$($ {
$(#dialog)对话框({
beforeclose:function .dialog('option','position',[$(this).offset()。left,$(this).offset()。top]);
$(this) ,'width',$(this).width());
$(this).dialog('option','height',$(this).height());
}
});
});

$('#dialog')。对话框('open')


I have a JQuery dialog that I dynamically open and close. Everything is working fine except the position of the dialog is not remembered after it is closed and then reopened.

The size is maintained but the position is not.

I have tried hooking into the 'Open' event but it appears that the position is being reset by JQuery UI after I manually reposition the element.

Is maintaining the size of the dialog possible? I certainly think it should be.

解决方案

You could use the jQuery UI Dialog "beforeclose" event to store the position and size. You can set both position and size using the "option" method.

Here is what currently works for me:

$(function() {
    $("#dialog").dialog({
        beforeclose: function(){
            $(this).dialog('option', 'position', [$(this).offset().left, $(this).offset().top]);
            $(this).dialog('option', 'width', $(this).width());
            $(this).dialog('option', 'height', $(this).height());
        }
    });
});

$('#dialog').dialog('open')

这篇关于JQuery UI对话框可以记住它在打开和关闭之间的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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