Reputation: 302
I made the HTML5 drag and drop working fine for single element. This is working good across the multiple browsers too e.g. i have two same or different browser windows open and i can drag from one browser and drop the element into the dropzone of another browser - this works fine for single element.
Has anyone idea how to make this work if want to select multiple elements and drag drop ?
Upvotes: 3
Views: 5285
Reputation: 8002
You cannot drag more than one thing at a time, what you would need to do is something along these lines. In this example suppose we have a multi select list, when you drag one selected element, all selected elements should be dragged.
See example here jsfiddle
$(".draggableThingsSelector").on("dragstart", function(e) {
e = e.originalEvent;
var fruitList = [],
dragImage = document.createElement("ul");
$("li.selected").each(function() {
fruitList.push(this.innerHTML);
dragImage.appendChild(this.cloneNode(true));
});
e.dataTransfer.setData("fruits", JSON.stringify(fruitList));
});
Also see here for more discussion of drag image support :drag image support
Upvotes: 6