ber*_*rko 2 javascript css jquery dialog jquery-ui
我有一个动态打开和关闭的JQuery对话框.一切都工作正常,除了关闭后重新打开对话框的位置.
尺寸保持不变,但位置不是.
我已经尝试连接到'Open'事件但是在我手动重新定位元素之后,JQuery UI似乎正在重置该位置.
是否可以保持对话框的大小?我当然认为它应该是.
您可以使用jQuery UI Dialog"beforeclose"事件来存储位置和大小.您可以使用"选项"方法设置位置和大小.
以下是目前适用于我的内容:
$(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());
}
});
});
Run Code Online (Sandbox Code Playgroud)
$( '#对话').对话框( '公开')