【问题标题】:Open a jquery modal dialog on the left side of the window在窗口左侧打开一个 jquery 模态对话框
【发布时间】:2013-04-03 20:57:34
【问题描述】:

我正在使用 jquery 模态对话框,我需要能够将其定位在页面的左侧,但我的代码无法设置位置。我做错了什么?

var $dialog;
function dialog(url) {
    $.get(url, {}, function (html) {
        $dialog = $('<div id="dialog" title="Create New Case"></div>').dialog({
            autoOpen: false,
            modal: true,
            close: function () {
                $("#dialog").remove();
            }
        });
        $dialog.html(html);
        $dialog.dialog("option", "width", "auto");
        $dialog.dialog("option", "height", "auto");
        $dialog.dialog("option", "left", "1%");
        $dialog.dialog("open");
    });
}

【问题讨论】:

    标签: jquery dialog position


    【解决方案1】:

    它不起作用,因为 jQueryUI 对话框没有名为 left 的选项。

    使用position 选项代替as indicated in the docs

    请注意,您必须在打开对话框后设置位置,否则您会看到一些不寻常的结果,因为 jQueryUI 的位置功能不支持定位隐藏元素。

    【讨论】:

    • 我把它改成了 $dialog.dialog("option", "position", { my: "left", at: "left" });它还在破碎。有什么原因吗?
    • 您可能需要将of 元素添加到您的位置对象。
    • 我需要它位于页面的左侧。您发送给我的文档有:按钮我该怎么做才能使它成为页面?
    • 在没有指定 of 的情况下为我工作。 Here is a jsFiddle 显示它工作正常。
    • And an updated jsFiddle 显示居中和左对齐之间的切换。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-10
    • 1970-01-01
    • 1970-01-01
    • 2017-02-22
    • 2013-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多