jQuery ui 对话框:关闭对话框内容的“可拖动”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6736820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery ui Dialog: Turn off 'Draggable' for Dialog content
提问by Evan Layman
I'm having a brain fart and cannot seem to get the content of my jquery ui dialog to stop being 'draggable'. I turned off the draggable setting on the actual dialog pop-up, however, the content inside the box is still able to be dragged out of the box's view. I'd like to have a static positioned box and static positioned content within the box.
我有一个大脑放屁,似乎无法让我的 jquery ui 对话框的内容停止“可拖动”。我在实际的对话框弹出窗口中关闭了可拖动设置,但是,框内的内容仍然能够被拖出框的视图。我想要一个静态定位的盒子和盒子内的静态定位内容。
Here is my code:
这是我的代码:
$('.LinkBtn').click(function (e) {
e.preventDefault();
var OfferID = $(this).attr('id').substring(8);
$('#HiddenLinks_' + OfferID).show();
newDialog(OfferID);
});
function newDialog(OfferID) {
var divObj = $('#HiddenLinks_' + OfferID);
var $dialog = divObj
.draggable()
.dialog({
draggable: false,
autoOpen: false,
resizable: false,
modal: false,
title: $('#HiddenLinks_' + OfferID).attr('title')
}).draggable(false);
$dialog.dialog('open');
return false
}
Thanks!
谢谢!
回答by Sorin Haidau
$('#popup').dialog({
width: 600,
modal: true,
resizable: false,
draggable: false
});
In this example I disabled both draggable and resizable events on a dialog box.
在这个例子中,我在对话框上禁用了可拖动和可调整大小的事件。
回答by Annie Chandel
$("#test_id").dialog({
display: 'block',
width: 500,
modal: true,
resizable: false,
draggable: false,
buttons: {
"Ok": function() {
$(this).dialog("close");
}
}
});
回答by CIRCLE
When you do:
$("div").draggable({disabled:true})
the div becomes transparent, you can remove the class from disabled so this doesn't happen:$("div").removeClass(' ui-draggable-disabled ui-state-disabled');
当您这样做时:
$("div").draggable({disabled:true})
div 变得透明,您可以从 disabled 中删除该类,这样就不会发生这种情况:$("div").removeClass(' ui-draggable-disabled ui-state-disabled');
回答by user2544256
You could also just set the draggable to false by:
您也可以通过以下方式将 draggable 设置为 false:
$("div").draggable({disabled:true}) // this will disable dragging on a draggable object
$("div").draggable({disabled:false}) // this will enable dragging on a draggable object
回答by Er. ?ridy
If you want to stop user from re-sizing your dialog box you can use below code.
如果您想阻止用户重新调整对话框大小,您可以使用以下代码。
$("#yourDivId").dialog("option", "resizable", false);
This will disallow user from re-sizing your dialog box.
这将禁止用户重新调整对话框的大小。