Erez's solution works for me, but I found that its lack of encapsulation is frustrating. I would suggest using the following solution to avoid using global variables:
$("#sortable1").sortable({ connectWith: ".connectedSortable", helper: function (e, li) { this.copyHelper = li.clone().insertAfter(li); $(this).data('copied', false); return li.clone(); }, stop: function () { var copied = $(this).data('copied'); if (!copied) { this.copyHelper.remove(); } this.copyHelper = null; } }); $("#sortable2").sortable({ receive: function (e, ui) { ui.sender.data('copied', true); } });
Here's jsFiddle: http://jsfiddle.net/v265q/190/
Sean Anderson Nov 07 '13 at 18:31 2013-11-07 18:31
source share