[英]jQuery UI Draggable, Sortable - Disallow dragging element
this is the script I'm using: 这是我正在使用的脚本:
$(".nav .row").draggable({
connectToSortable: ".demo",
helper: "clone",
handle: ".drag",
drag: function (e, t) {
t.helper.width(400)
},
stop: function (e, t) {
$(".demo .column").sortable({
opacity: .35,
connectWith: ".column"
})
}
});
Basically what it does is that it allows dragging new rows and allows dragging elements inside columns inside these rows. 基本上,它的作用是允许拖动新行,并允许在这些行内的列内拖动元素。
Here is an example output: 这是示例输出:
<div class='demo'>
<div class='row'>
<div class='column'>
</div>
</div>
</div>
The problem with it is that it allows dragging another row inside that column class, I want to prevent this from happening, this is what happens: 它的问题是它允许在该列类中拖动另一行,我想防止这种情况发生,这是发生的情况:
<div class='demo'>
<div class='row'>
<div class='column'>
<div class='row'>
<div class='column'>
</div>
</div>
</div>
</div>
</div>
Can anyone give me some suggestions how I could prevent this from happening? 谁能给我一些建议,以防止这种情况的发生?
It's happening because $(".nav .row")
selects all elements with a class of .row
within nav container. 之所以会这样,是因为
$(".nav .row")
选择了nav容器中所有带有.row
类的元素。 You could add another class name to target specific rows, for example: 您可以添加另一个类名来定位特定的行,例如:
<div class='demo'>
<div class='row dragabble'>
<div class='column'>
</div>
</div>
</div>
$(".nav .draggable").draggable({
connectToSortable: ".demo",
helper: "clone",
handle: ".drag",
drag: function (e, t) {
t.helper.width(400)
},
stop: function (e, t) {
$(".demo .column").sortable({
opacity: .35,
connectWith: ".column"
})
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.