I’m trying to solve for a problem, and haven’t had much luck figuring it out on my own.
I have several container divs on my page. The “ItemContainer” holds “items” that are draggable. The “MainHome” holds a secondary “ItemContainer” (where the “items” are to be dragged to) as well as some other divs. The “MainHome” is also draggable into a “Playarea”. What I need to have happen, is when “items” are dragged into the “ItemContainer” contained within the “MainHome” they need to be attached to it so that if “MainHome” is then dragged, those items drag with it.
They will need to remain individually draggable as well.
Here is my generic code:
<div id="leftrail">
<div id="manager">
<div id="somediv">
<h2>Text</h2>
<div id="bubble">Text Here</div>
</div>
<div>
<div id="ItemContainer">
<div id="Item1">Item 1</div>
<div id="Item2">Item 2</div>
<div id="Item3">Item 3</div>
<div id="Item4">Item 4</div>
<div id="Item5">Item 5</div>
</div>
</div>
</div>
<h2>Section Title</h2>
<div>
<div id="MyContainer">
<div id="SecondaryItemContainer">Drag Items Here</div>
<div>Some text</div>
<div>Some more text</div>
</div>
</div>
</div>
<div id="MainContent">
<div>Some stuff here</div>
<div>Some stuff here</div>
<div>Some stuff here</div>
<div id="BigContainer">Drag the MyContainer Here</div>
</div>
The full demo here: http://jsfiddle.net/j6pVG/1/
Here’s a nested sortable solution: http://mjsarfatti.com/sandbox/nestedSortable/
And here’s an improvement on how the serialization is handled in the above solution: http://markmintoff.com/2011/05/jqueryui-hierarchical-sorting/
Another solution: http://dbushell.com/2012/06/17/nestable-jquery-plugin/
And, here are the SO duplicates of this question: