albanx
albanx

Reputation: 6335

jquery dialog: drag dialog at any point

Is there a trick to make a jquery dialog be draggable at any point? (i mean not only in the title bar)

Upvotes: 4

Views: 2071

Answers (2)

user1711838
user1711838

Reputation:

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

Upvotes: 0

peol
peol

Reputation: 872

As opposed to a sortable item, dialog items doesn't have that functionality (I'm not sure why). If needed, you might be able to do something like this:

$(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: ''});
});

See a working example here: http://jsfiddle.net/gMP2d/

Upvotes: 2

Related Questions