JAVASCRIPT FUNCTIONS :
<body>
function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { //ev.dataTransfer.setData("text", ev.target.id); DI.trip_id = $(this).attr('trip_id'); DI.drag_id = ev.target.id; } //Drop with originalfunction drop_original(ev) { ev.preventDefault(); var data_id = DI.drag_id; var elm_id = ev.target.id; ev.target.appendChild(document.getElementById(DI.drag_id)); //$("#"+elm_id).find('.time-slot-detail').append(document.getElementById(data));}
//Drop with copyfunction drop_copy(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("text/html"); /* If you use DOM manipulation functions, their default behaviour it not to copy but to alter and move elements. By appending a ".cloneNode(true)", you will not move the original element, but create a copy. */ var nodeCopy = document.getElementById(DI.drag_id).cloneNode(true); nodeCopy.id = "newId"; /* We cannot use the same ID */ ev.target.appendChild(nodeCopy); }
http://stackoverflow.com/questions/13007582/html5-drag-and-copy
No comments:
Post a Comment