Currently jquery ui dialog is draggable only on the titlebar
What's the recommended way to make jquery ui dialog be draggable by the entire dialog instead of just the titlebar?
I just did
elem.dialog({draggable: false}).draggable()
Anything wrong with this?
Currently jquery ui dialog is draggable only on the titlebar
What's the recommended way to make jquery ui dialog be draggable by the entire dialog instead of just the titlebar?
I just did
elem.dialog({draggable: false}).draggable()
Anything wrong with this?
Share Improve this question edited Jun 20, 2011 at 12:05 Harry asked Jun 20, 2011 at 11:54 HarryHarry 54.9k76 gold badges185 silver badges270 bronze badges 4 |2 Answers
Reset to default 15Well, elem.dialog({draggable: false}).draggable();
won't work, because as other answers have said, it's not the right element. However, this will work:
elem.dialog({draggable: false}).parent().draggable();
I think it's a better option than fiddling with jquery internals.
Currently jQueryUI prevents the content from being draggable with this code:
self.uiDialog.draggable({
cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
handle: ".ui-dialog-titlebar",
...
});
So, to make the change you require you'll need to access that internal uiDialog
object and change its settings.
If dlg
is your dialog content object:
$(dlg).data('dialog').uiDialog.draggable('option', {
cancel: '.ui-dialog-titlebar-close',
handle: '.ui-dialog-titlebar, .ui-dialog-content'
})
will work.
Note that this is futzing with jQueryUI internals and may break if those internals are changed by future updates.
elem.dialog({draggable: false}).draggable()
work? If so then I'd say that's the answer. – Town Commented Jun 20, 2011 at 12:11