JQuery对话框包含 [英] JQuery Dialog containment

查看:115
本文介绍了JQuery对话框包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



编辑:哦,抱歉,我的意思是..

解决方案

您可以定位对话框并对其应用遏制。尝试这样:

  var container = $('。dialog-container'),
dialog = $(' UI-对话框');
//获取容器左上角的位置
var cx1 = container.offset()。left,
cy1 = container.offset()。
//获取对话框大小
var dw = dialog.outerWidth(),
dh = dialog.outerHeight();
//获取容器底部正确的位置,然后减去对话框大小
var cx2 = container.width()+ cx1 - dw,
cy2 = container.height()+ cy1 - dh;
dialog.draggable(option,containment,[cx1,cy1,cx2,cy2]);

编辑:我设置了演示

Edit2:更改为使用对话框outerWidth& outerHeight


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

Edit: Oh sorry containment I meant..

解决方案

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.outerWidth(),
    dh = dialog.outerHeight();
// 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.
Edit2: Changed to use dialog outerWidth & outerHeight

这篇关于JQuery对话框包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆