jquery对话框:随时拖动对话框

时间:2010-07-27 14:33:46

标签: javascript jquery-ui draggable

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

2 个答案:

答案 0 :(得分:2)

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

$(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/

答案 1 :(得分:0)

$("#div_id")
    .dialog({
        position: [3,442],
        width: 300,
        height: 90
    })
    .css({cursor: 'move'})
    .parent()
    .draggable({cancel:'',handle:''});
相关问题