【问题标题】:jquery dialog: drag dialog at any pointjquery 对话框:在任意点拖动对话框
【发布时间】:2010-07-27 14:33:46
【问题描述】:

是否有一个技巧可以让 jquery 对话框在任何时候都可以拖动? (我的意思不仅仅是在标题栏中)

【问题讨论】:

  • 好问题,虽然我喜欢它像其他窗口一样工作的事实,可以通过标题栏拖动。

标签: javascript jquery-ui draggable


【解决方案1】:

与可排序项目相反,对话框项目没有该功能(我不确定为什么)。如果需要,您可以执行以下操作:

$(document).ready(function() {
    var
        // Create dialog
        dialog = $('div')
            .dialog({ title: "I'm a dialog" })
            .css({cursor: 'move'}),

        // Get the options manually
        options = dialog
            .data("dialog")
                .uiDialog
                .data('draggable')
                    .options;

    // Finally, extend the draggable modal box's
    // options and remove any restrictions
    $.extend(options, {cancel: '', handle: ''});
});

在此处查看工作示例:http://jsfiddle.net/gMP2d/

【讨论】:

    【解决方案2】:
    $("#div_id")
        .dialog({
            position: [3,442],
            width: 300,
            height: 90
        })
        .css({cursor: 'move'})
        .parent()
        .draggable({cancel:'',handle:''});
    

    【讨论】:

    • 你为什么要使用 $('#div_id') 的父容器而不只是让 $('#div_id') 可拖动?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 2011-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多