On Tue, Jan 6, 2009 at 4:16 AM, vorob...@gmail.com <vorob...@gmail.com>wrote:

>
> Hello,
> I'm having a problem, perhaps anyone can spot what the problem is.
> For some reason, the following syntax does not
> My concern is the <draggable> thingy. I want the dialog box be
> draggable only within the browser's internal window borders.
> This is how I understand it should work:
>
>        dBox.dialog({
>                modal: true,
>                draggable:true,
>                stack:true,
>                zIndex:1000
>        }).draggable({ containment: 'window' });
>
> but it doesn't work for some reason.
> anyone has got a thought about this?
>

This doesn't work because you create a dialog by calling .dialog() on the
element that makes up the content of the dialog. It then gets wrapped by a
div that is made draggable. So your .draggable call above is actually on the
dialog content element, not the dialog element. For more details, see
http://jqueryui.pbwiki.com/Dialog (section 3 - Specifications)

To keep the API simple, dialog doesn't expose all draggable options, but as
a work-around, you can override any at the draggable level, before calling
.dialog():

$.extend($.ui.draggable.defaults, {
    containment: 'window'
});

Also, note that in the latest trunk (after 1.6rc4) dialog has been changed
to default to draggable containment: document. So this may not be needed in
the future.

- Richard

Reply via email to