JQ UI Drag and Clone

by Al Kasih

HTML

<ul id="left-pane">
   <li><img src="https://www.google.com/images/srpr/logo3w.png" /></li>
    <li><div contenteditable="true"></div></li>
</ul>

<ul id="right-pane">
</ul>

CSS

#left-pane
{
    border: 1px solid black;
    min-width: 100px;
    min-height: 100px;
}

#right-pane
{
    border: 1px solid black;
    min-width: 100px;
    min-height: 100px;
}

div {
   width: 200px; 
    height: 200px; 
    background: red; 
}

JavaScript

$("#left-pane li").draggable({
    containment: '#gbox',
    cursor: 'move',
    helper: 'clone',
    scroll: false,
    connectToSortable: '#right-pane',
    appendTo: '#right-pane',
    start: function () {},
    stop: function (event, ui) {}
}).mousedown(function () {});

$("#right-pane").sortable({
    sort: function () {},
    placeholder: 'ui-state-highlight',
    receive: function () {},
    update: function (event, ui) {}
});

$("#right-pane li").live('dblclick', function () {
    $(this).remove();
})

$("#right-pane").droppable({
    accept: "#left-pane li",
    accept: ":not(.ui-sortable-helper)",
    drop: function (event, ui) {
        if ($(ui.draggable).find('.single-item').length == 0)
        {
        	$(ui.draggable).append("<div class='single-item'><input type='text' class='item-title' /><br /><textarea class='item-text'></textarea></div>");
        }
    }
});

$("#left-pane").droppable({
    accept: "#right-pane li",
    drop: function (event, ui) {}
});

$("ul, li").disableSelection();