Is there a way to have nested jQuery sortables? As in nested containers, not in the sense of a nested list.
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="container">
<div class="item"></div>
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="item"></div>
</div>
$('.container').sortable({
connectWith: '.container'
});
http://jsfiddle.net/ExLqv/2/
That example pretty much works, but when I drop the nested container I get an error:
Uncaught HierarchyRequestError: A Node was inserted somewhere it doesn't belong.
I assume it is because when dragging a container
it is positioned under the mouse, so when I drop it, it trys to put it inside itself.
I have a work around, although not ideal so the question still stands.
$('.container').sortable({
connectWith: '.container:not(.ui-sortable-helper)',
tolerance: "pointer",
cursorAt: { left: -50 }
});
http://jsfiddle.net/ExLqv/8/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…