简体   繁体   中英

jQuery UI - Prevent dialog from dragging above div

Is there a way to prevent jQuery UI dialog from going above or below #top div? I'm not looking for z-index solution, but rather something like offset from the top. In this case dialog should be unable to be moved to area where is #top div.

Any suggestions?

HTML:

<div id="top"></div>
<div id="dialog">My dialog</div>

JS:

$(document).ready(function() {
    jQuery("#dialog").dialog({
                            autoOpen:true,
                            modal: false,
                            resizable: true,
                            draggable: true,
                            closeOnEscape: true,
                            title: "Title",
        open: function(){
            jQuery('.ui-widget-overlay').bind('click',function(){
                jQuery('#dialog').dialog('close');
            })
        }
    });
});

JSFIDDLE: https://jsfiddle.net/9gku6qrh/

这可能就是您要寻找的内容- 在div中保留一个jQuery对话框 -您只需要在#dialog周围放置一个父容器#dialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM