It seems very simple but I could not get this to work. I’ve two draggables inside 2 different droppables. When I place a draggable from one droppable to another, the existing draggable should animate to move into another droppable area.
$('.droppable').droppable({
hoverClass: 'hoverClass',
drop: function(event, ui) {
var $from = $(ui.draggable),
$fromParent = $from.parent(),
$to = $(this).children(),
$toParent = $to.parent();
// This is where I replace draggables' positions without animation
$toParent.html($from.css({left: '', top: '', 'z-index': ''}));
$fromParent.html($to);
makeDraggable();
}
});
Woohoo!!! I figured it out myself.
Demo: http://jsfiddle.net/codef0rmer/AywmJ/2/
Just wrote this small code for swapping:
and updated drop event: