Ciel
Ciel

Reputation: 17782

jQuery Sortable, Restrict to 1 item

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>

Upvotes: 0

Views: 233

Answers (1)

OneNerd
OneNerd

Reputation: 6552

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.

Upvotes: 1

Related Questions