Reputation: 6335
I have some sortable connected list, that are at the same time droppable places. The problem is that when I call the cancel method of sortable in the drop event of droppable, the sortable is broken and wont work any more. Example http://jsfiddle.net/zSnBA/10/ try to move the div number 102 on the second list: you will see that the cancel event will be called but the sortable wont work any more? Any help?
Upvotes: 7
Views: 4476
Reputation: 126052
I would recommend not making the sortable list draggable as well, but listen to the receive
event on sortable to cancel the event:
$('div.products-list').sortable({
connectWith: '.products-list',
placeholder: 'ui-state-highlight',
items: 'div.product',
revert: 200,
receive: function(event, ui) {
var prod_id = ui.item.attr("prod_id");
/* Equal to 1 is valid because an item was just added to the list: */
if ($(this).find(".product[prod_id='" + prod_id + "']").length > 1) {
ui.sender.sortable("cancel");
}
}
});
Example: http://jsfiddle.net/z5X5y/
Upvotes: 6