Dimitar
Dimitar

Reputation: 484

jQuery sortable() - move elements to connected list before first element that is not sortable

I have two connected sortable lists. The second contains only one element and it can't be moved ( but the list is sortable ).

When I move element from the first list to the second, I can't add the new element as first element of the second list.

Always first element of the second list is 5 (in this example). http://jsfiddle.net/fuQ4Z/ Example .

Ideas how to solve this problem ?

Thanks

Upvotes: 0

Views: 754

Answers (1)

gulty
gulty

Reputation: 1076

I assume you want the li of your #sortable2 to be sortable but not connected with the other list or draggable. To accomplish this just add another class to the list element and exclude it. http://jsfiddle.net/fuQ4Z/3/

$( "#sortable1, #sortable2" ).sortable({
  connectWith: ".connectedSortable",
  items: "li:not(.new)",
  cancel: '.excluded'
}).disableSelection();

I gave the li element on #sortable2 a excluded class instead of the new class..

<li class="ui-state-highlight excluded">Item 5</li>

Upvotes: 1

Related Questions