javascript - HTML5 Dragging and Dropping multiple elements between multiple browser windows - Stack Overflow

I made the HTML5 drag and drop working fine for single element. This is working good across the multipl

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 ?

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 ?

Share Improve this question asked Aug 18, 2011 at 12:14 DipakRiswadkarDipakRiswadkar 3022 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

  1. Listen for a dragstart event on one of the draggables
  2. When setting the dataTransfer - you need to encode data in there that will represent all the stuff you want dragged.
  3. Customise the drag image to show the user more than one thing is being 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744851397a4597148.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信