Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello frnds,

I have a screen with contain 9 div grid.

And another one is a single div which can drag and drop on one of div of grid

Now the requirement has change ,

Now i want to drop dragable div to multiple div of grid

Now my question is how can i drop on multiple div

Thanks.
Posted
Comments
Peter Leow 25-Dec-13 11:36am    
Do you mean to drag and drop a copy of that single div into one or more of the 9-div grid while that original single div stays as it is?
ExpertITM 25-Dec-13 23:32pm    
No, The dragable div will be as of dropable number of div
Peter Leow 26-Dec-13 0:22am    
So you want to drag and drop that div to all the other 9 divs all at once, right? See my amended solution.

try this solution given in this link as it is not fully customized to your needs but some how might be helpful to some extent
http://www.jeasyui.com/tutorial/dd/dnd1.php[^]

or this link also might helps you http://stackoverflow.com/questions/18204135/create-nested-drag-and-drop-divs-with-jquery-ui[^]

and this is similar requirement as like your http://forum.jquery.com/topic/drag-and-drop-one-div-to-many-divs[^]

u need to go thru all the links and have to do a little work around to make things work for you.
 
Share this answer
 
Now, it is clearer, So you want to drag and drop a div to all the other 9 divs all at once, right? Try the following demo code and adapt:

XML
<!doctype html>
<head>
<title>jQuery Drag and Clone</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script>
$(document).ready(function(){

    $("#draggable").draggable({helper:'clone'});

    $(".dropsite").droppable({
            accept: "#draggable",
            drop: function(event,ui){
            $(this).children().append($(ui.draggable).clone());
            $("#draggable").remove();
            }
    });
});
</script>
</head>
<body>
<div id="draggable" style="width:150px; height:150px; background-color:#0000ff; color:white;">Drag a Copy</div>

<div class="dropsite">
   <div style="width:150px; height:150px; background-color:#333333; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#bbbbbb; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#333333; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#bbbbbb; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#333333; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#bbbbbb; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#333333; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#bbbbbb; color:white;"></div>

   <div style="width:150px; height:150px; background-color:#333333; color:white;"></div>
</div>
</body>
</html>


The idea here is to clone the draggable div, drop it into all the children divs in dropsite, lastly remove the draggable div.
 
Share this answer
 
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900