The error is a result of having a div.sortable nested in another div.sortable, so it it fires the sorting twice when you drop in a new element. The workaround I came up with just counts the number of elements added in a particular drop and adds a class called 'deleteMe' to the duplicates.
Then you just call $(".deleteMe").remove() at the end of a sort to remove the extras.
Not ideal, but seems to work for me. http://jsfiddle.net/JUnA7/72/
$(function() {
var dropCount=0;
$(".sortable").sortable({
connectWith: ".sortable",
cursor: 'pointer',
receive: function(event, ui) {
dropCount=dropCount+1;
if(dropCount>1)
$(ui.item).addClass("deleteMe");
console.log(dropCount);
},
start: function(event, ui) {
dropCount=0;
var placeholders=0;
$(".ui-sortable-placeholder").each(function(){
placeholders=placeholders+1;
if(placeholders>1)
$(this).height(0);
});
},
stop: function(event, ui) {
$(".deleteMe").remove();
dropCount=0;
}
});
$(".draggable").draggable({
handle: ".icon-move",
connectToSortable: ".sortable",
appendTo: "body",
helper: 'clone',
distance: 30
});
});
UPDATED
Also, I noticed that the sorting placeholders a duplicated too..so I removed the duplicates by setting their height to 0px.
start: function(event, ui) {
dropCount=0;
var placeholders=0;
$(".ui-sortable-placeholder").each(function(){
placeholders=placeholders+1;
if(placeholders>1)
$(this).height(0);
});
}