I haven’t seen any examples of selective sortables:
[A: one master list]
[B: one sublist]
[C: another sublist]
Conditions:
- B and C can transfer to A
- A can only transfer to B the elements that came from B (the same applies to C)
- B and C cannot transfer between eachother
Example Structure:
<ul class="A"></ul>
<ul class="B">
<li class="child-B" />
<li class="child-B" />
<li class="child-B" />
</ul>
<ul class="C">
<li class="child-C" />
<li class="child-C" />
<li class="child-C" />
</ul>
I’ve tried applying sortable to the lists and trying to dynamically alter the connectWith afterwards (they’d all be able to connect to A), but no luck. Here’s one of my attempts (jsFiddle). I also tried putting ‘.master,.sub’ as the initial connectWith, but it allows cross sharing.
I think the second looping is updating the sortable’s connectWith, so I’m stuck. Any ideas?
This is the first time that I’ve played around with
sortable(with a bit of reading from jqueryui.com) but I think this should do the trick. You can see it in action at the following jsFiddleHTML:
JQuery:
This example basically performs the validation on receiving the item, and if it doesn’t pass, it cancels the move.
Hope it’s what you’re looking for.