When dragging an element on the droppable area, append the element directly. When dragging an element on a droppable item, insert the element before the droppable item. The key code below shows how to implement this functionality:
var drop_conf = {
onDrop:function(e,source){
if ($(this).hasClass('drag')){ // drop on inner item
$(source).insertBefore(this);
} else {
$(this).append(source)
}
$(this).removeClass('over');
$(source).droppable(drop_conf);
e.stopPropagation();
}
}
$('#target').droppable(drop_conf);