最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery ui dialog draggable on entire dialog not just title - Stack Overflow

programmeradmin1浏览0评论

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
  • Could you be a bit more specific? Some html would be helpful. – dave Commented Jun 20, 2011 at 12:00
  • I would assume it's using a handle for the draggable property. Perhaps there is a configuration setting for this which would make the whole item draggable. – ek_ny Commented Jun 20, 2011 at 12:09
  • Does elem.dialog({draggable: false}).draggable() work? If so then I'd say that's the answer. – Town Commented Jun 20, 2011 at 12:11
  • I wouldn't expect that to work - it would probably make the dialog's contents draggable within its dialog frame. – Alnitak Commented Jun 20, 2011 at 12:23
Add a comment  | 

2 Answers 2

Reset to default 15

Well, 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.

发布评论

评论列表(0)

  1. 暂无评论