Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach draggable div to another div

I'm trying to use jQuery UI draggable/droppable plugins.

I have draggable div that I drag onto target div. Target div is also draggable. I can't seem to be able to figure out a way to attached divs to their target to move them together when I drag target div.

Any pointers in the right direction would be highly appreciated.

like image 430
santa Avatar asked Mar 27 '11 19:03

santa


People also ask

Can Div be draggable?

Draggable Div is a kind of element that you can drag anywhere. Here I have created a Draggable profile card.

How do I limit a draggable area?

Limit draggable area using 'containment' option It is simple. All you have to do is, add an option called containment to the draggable() method. The containment option has a value parent.

How do I make content draggable?

To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page.


1 Answers

Is this what you're trying to achieve? http://jsfiddle.net/wfG3L/5/

If you want to add the draggable div, you can just use $(ui.draggable) directly and append it to the target div, that way you don't have to specify the dropped divs in the .stackDrop to be draggable.

like image 80
Xnake Avatar answered Sep 28 '22 02:09

Xnake