tags:

views:

74

answers:

1

Hello

Is it possible to add containment to JQuery's Dialog?

Edit: Oh sorry containment I meant..

+1  A: 

You could target the dialog box and apply a containment to it. Try this:

var container = $('.dialog-container'),
    dialog = $('.ui-dialog');
// get container top left corner locations
var cx1 = container.offset().left,
    cy1 = container.offset().top;
// get dialog size
var dw = dialog.width(),
    dh = dialog.height();
// get container bottom right location, then subtract the dialog size
var cx2 = container.width() + cx1 - dw,
    cy2 = container.height() + cy1 - dh;
dialog.draggable( "option", "containment", [cx1, cy1, cx2, cy2] );

Edit: I set up a demo for you.

fudgey
Hey thanks a lot!!!!
PPPHP