【问题标题】:Jquery position is not giving expected resultJquery位置没有给出预期的结果
【发布时间】:2013-10-30 03:39:44
【问题描述】:

我正在将 Jquery 版本从 jquery-1.6.4.min.js 升级到 jquery-1.10.2.js

和 jquery ui 版本从jquery-ui-1.7.2.js 到 jquery-ui-1.10.3.js

我还包含了最新版本的 jquery-ui.css。

这是我正在使用的脚本标签。

<script type="text/javascript" src="JS/jquery-1.10.2.js"></script> 
<script type="text/javascript" src="JS/jquery-ui-1.10.3.js"></script> 

这样我就打开了一个对话框。

dialog = $('#dialog-modal-error');
dialog.html (l_str);
dialog.dialog(); /* if i am not using this then it is giving me this error msg.  cannot call methods on dialog prior to initialization; attempted to call method 'option'*/
if (dialog.dialog ('option', 'disabled') == undefined) {
    dialog.dialog (
        {
            autoOpen: true,
            position : { my: 'center', at: 'center'},
            modal : false,
            bgiframe : true,
            buttons: {},
            close : minimizeMessages,
            resizable : false,
            draggable : false
        }

    );


} else {
    dialog.dialog ('open');

}

因此它总是在页面右下角打开我的对话框,所以只想知道为什么它会显示这种行为。

我已经检查了所有的 css,它没有采用任何继承的 css。

编辑:

我也用过这个 position : { my: 'center', at: 'center', collison: 'none'} 但没用。

使用最新版本的 jquery 可以正常工作。

注意:对话框总是从屏幕中出来(左-下)

【问题讨论】:

    标签: javascript jquery css jquery-ui


    【解决方案1】:

    查看 jQuery UI 文档 (http://api.jqueryui.com/dialog/#option-position),您似乎已经忽略了 of 属性。 position 的默认值为 { my: "center", at: "center", of: window }。所以尝试指定of: window 属性。

    【讨论】:

    • 我已经检查过了,但这也不是我预期的行为。
    【解决方案2】:

    使用 'of' 属性来正确定位它。您希望它放在哪里?

    例如:

    position:{ my: "center", at: "center", of: $("#aDiv")}
    

    这也可以读作: 将我的对话框的中心放置在 ID 为 aDiv 的 div 的中心。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-29
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-09
      • 2021-01-06
      相关资源
      最近更新 更多