Я использовал комбинацию решений для достижения этого, с #large_tiles и #small_tiles, являющимися двумя списками:
$(function() {
$("#large_tiles li, #small_tiles li").draggable({
zIndex: 2,
appendTo: "body",
});
initDroppable($("#large_tiles li, #small_tiles li"));
initSwap();
function initSwap() {
initDroppable($("#large_tiles li, #small_tiles li"));
initDraggable($("#large_tiles li, #small_tiles li"));
}
function initDraggable($elements) {
$elements.draggable({
zIndex: 2,
appendTo: "body",
helper: "clone",
start: function(e, ui) {
$(ui.helper).addClass("clone");
},
cursorAt: { left:50, top:75 }
});
}
function initDroppable($elements) {
$elements.droppable({
activeClass: "active-tile",
hoverClass: "hover-tile",
over: function(event, ui) {
var $this = $(this);
},
drop: function(event, ui) {
var $this = $(this);
var linew1 = $(this).after(ui.draggable.clone());
var linew2 = $(ui.draggable).after($(this).clone());
$(ui.draggable).remove();
$(this).remove();
initSwap();
}
});
}
});