jQuery对话框:可以在任意位置拖动对话框

4
有没有什么方法可以使jquery对话框在任何位置可拖动?(我的意思是不仅限于标题栏)

好问题,虽然我喜欢它像其他窗口一样工作,可以通过标题栏拖动。 - Mark Schultheiss
2个回答

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/

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

为什么要获取 $('#div_id') 的父容器,而不是直接将 $('#div_id') 设置为可拖动? - Konstantin Dinev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接