我可以强制对话框仅在窗口内部拖动吗? [英] Can I force the dialog draggable only inside the window?

查看:156
本文介绍了我可以强制对话框仅在窗口内部拖动吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html:

    <div id="dialog" title="Past Issues">
    </div>

jQuery:

$( "#dialog" ).dialog({
        height: 900,
        width:1200,
        modal: true,
});

问题是当前对话框可以拖动到窗口区域的几厘米处,是否可以设置包含窗口的容器?还是默认设置已经是containment:窗口?如果是,问题的根源是什么?谢谢.

The problem is currently the dialog can be drag to few more cm of the window area, is it possible to set the containment is the window? Or the default setting is already is containment : window? If yes, what is the root course of the problem? thanks.

推荐答案

尝试一下,对于演示,我使用了div,您可以将其替换为window

Try this, for demo I have used a div you can replace it with window

$("#dialog").dialog({
    open: function(event, ui) {
        var vDlg = $(event.target).parent();
        var vCont = $('#main');   // for window use - $(window);
        vDlg.draggable("option", "containment", vCont).appendTo(vCont);
        $(this).dialog("option", "position", "center");
    }
});​

此处演示

这篇关于我可以强制对话框仅在窗口内部拖动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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