Reputation: 2621
I have connected sortable list A and B. One item is fixed in list A called forbidden
so that it cannot be sorted. When list A is empty (only with forbidden left) and trying to add item from list B, the item always get inserted after the fixed item (forbidden) in list A. I want it before fixed item (forbidden) in list A. I want it using jquery-ui-sortable without using any plugins.
Here is my fiddle
#UPDATE
Check this image. Isabelle from list B can be placed under forbidden when list A is empty (i.e, when list A contain only forbidden
Upvotes: 1
Views: 72
Reputation: 9927
You can do it by cancel option and cancle method like this:
$(function() {
$(".list-A, .list-B").sortable({
update: function(event, ui) {
if ($(this).find('.forbidden').length > 0) {
if ($('.forbidden').index() < $(this).children().length - 1)
$('.sortable').sortable("cancel");
}
},
connectWith: ".sortable",
cancel: '.forbidden'
}).disableSelection();
});
Upvotes: 1