问题
Is there anyway to keep a jQueryUI
overlay in the same DOM position?
Take a look at this
HTML
<div id="parent">
<div id="over" title="title">
Stuff
</div>
</div>
JS:
$('#over').dialog({modal: true});
If you inspect it on the DOM, you'll notice that the overlay gets moved to a direct child of document.body
Is there any way to keep it in it's starting position? (direct child of div#parent
)?
回答1:
Not sure why you want this, but something like: http://jsfiddle.net/BGBuc/ should get you started.
JS
$('#over').dialog({
modal: true,
create:function(event, ui) {
setTimeout(function(){
$('#parent').append($('div.ui-widget-overlay')).append($('div.ui-dialog'));
},1);
}
});
来源:https://stackoverflow.com/questions/10033228/keep-jqueryui-overlay-in-same-dom-position