JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<div id="list"></div>
CSS
.list-entry {
}
.list-subentry {
padding-left: 20px;
}
JavaScript
var items = [
{ text: 'Item 1' },
{
text: 'Item 2',
items: [
{ text: 'Subitem 1' },
{
text: 'Subitem 2',
items: [
{ text: 'Entry A' },
{ text: 'Entry B' }
]
}
]
},
{ text: 'Item 3' }
];
function addItems(itemList, parent, indent) {
for (var i = 0; i < itemList.length; i++) {
var div = $('<div class="' + (indent ? 'list-subentry' : 'list-entry') + '"/>');
div.text(itemList[i].text);
div.appendTo(parent);
if (itemList[i].items != undefined)
addItems(itemList[i].items, div, true);
}
}
function makeDraggable() {
$(this).draggable({
revert: true,
proxy: 'clone'
}).droppable({
accept: 'list-entry list-subentry',
onDragOver: function(e, source) {
},
onDragLeave: function(e, source) {
},
onDrop: function(e, source) {
}
});
$(this).children('div').each(makeDraggable);
};
$(function() {
addItems(items, $('#list'), false);
$('#list').children('div').each(makeDraggable);
});