I've got a simple setup using jQuery UI's default sortable/draggable functionality.
I now need to add a 'palette' which will will be a list of all items in all lists (and some that may not be in any lists). Like this:
<ul id="palette" class="ui-sortable">
<li class="used">A</li>
<li>B</li>
<li class="used">C</li>
<li class="used">D</li>
<li>E</li>
<li>F</li>
</ul>
<ol id="box1" class="ui-sortable box">
<li>A</li>
<li>D</li>
</ol>
<ol id="box2" class="ui-sortable box">
</ol>
<ol id="box3" class="ui-sortable box">
<li>C</li>
</ol>
At the moment, the palette doesn't do anything different - dragging items in and out simply moves them.
The functionality I need is that when I drag out of the palette, it copies rather than moving, and when I drag into the palette, it removes from the source list but doesn't add to the palette. (The boxes can store multiple copies of palette items.)
I've used the sortable's receive
event to create something that does all this - and I've added that as an answer below - but I want some things that my existing solution doesn't provide:
- preserve (visually, at least) the item in the palette from start of drag (rather than restoring it after dropping).
- persist the original palette order, preventing sortability (but preserving ability to connect with it from boxes).
Can anyone suggest how best to implement these?