Here's the Fiddle
I have a table with draggable rows that are multi-selectable, but I want to drag them en masse to another table and drop them there - not to be appended as additional elements to the other table, but to do some stuff with the information, i.e. form submission.
My example is originally based on another demo I found here: multi drag demo
Here is the HTML code for the basic example of this problem.
<table class="DraggableThings">
<tr draggable='true'><td >Row 1</td></tr>
<tr draggable='true'><td >Row 2</td></tr>
<tr draggable='true'><td >Row 3 </td></tr>
</table>
<table id='menu_table'>
<tbody>
<tr>
<td class='droppableItem' >accomplished</td>
</tr>
</tbody>
</table>
Here is the JQuery code
$('.droppableItem')
.bind('dragenter dragover', false)
.bind('drop', function(event){
accomplished($(this),event);
});
$('.DraggableThings tr').bind('click', function () {
$(this).toggleClass("selected");
});
$('.DraggableThings tr').bind('dragstart', function(event){
var mytext = event.target.innerText;
event.originalEvent.dataTransfer.setData('txt', mytext );
});
$('.DraggableThings tr').drag("init", function () {
return $('.selected');
}).drag(function (ev, dd) {
$(this).css({
top: dd.offsetY,
left: dd.offsetX
});
});
function accomplished(thing,event) {
event.dataTransfer = event.originalEvent.dataTransfer;
var data = event.dataTransfer.getData('txt');
log(data + " made it to accomplishments");
}
css
.selected {
background-color: #ECB;
}
Here's the Fiddle
Hope someone knows the answer Thank you