tags:

views:

45

answers:

1

I'm trying to build a jQuery sortable list that has two lists, an available, and an 'allocated'. The 'allocated' list receives items from the 'available' list, and only one item can be 'allocated' at any one time. Is it possible to enforce this kind of constraint without a lot of additional logic/checks in the jQuery UI?

<ul id="available">
 <li>Item 1</li>
 <li>Item 2</li>
 <li>Item 3</li>
</ul>

<ul id="allocated">
 // only one item should be allowed to be dropped here.
</ul>
+1  A: 

I suspect you could unset the drop target (#allocated) once something is dropped there (using callback function when item is dropped), and then reset drop target when it is dragged back to #available.

OneNerd
Thank you! I hadn't considered that. I'll just use css classes 'droppable' and 'removable'. And have them added/removed on the receive/remove functions of the sortable.
Stacey