Wizzard
Wizzard

Reputation: 12702

jquery draggable / sortable with disabled items

Using the include and exclude example, I am trying to make it so if two items are excluded and item can't be dropped between them.

Review the url; http://jqueryui.com/sortable/#items

The top example is almost perfect except item's can't be dropped before or after the lists (move item 4 to the top, then try and put item 4 back, wont let you).

In the second example items can be put before/after and between the disabled items, which again is half way to what I want.

Is there a way to make it so disabled items can't be inserted between?

Upvotes: 0

Views: 320

Answers (1)

DGS
DGS

Reputation: 6025

The Following fiddle has a working example if you know that all the disabled options are going to be next to each other. It adds a dropable spot just after the last disabled spot.

Fiddle

 $(function () {
     $("#sortable1").sortable({
         items: "li:not(.ui-state-disabled),li.ui-state-disabled:last-child"
     });
     $("#sortable2").sortable({
         cancel: ".ui-state-disabled"
     });
     $("#sortable1 li, #sortable2 li").disableSelection();
 });

Upvotes: 1

Related Questions