# Draggable\_element: How to get id of dragged element, AND rec

**URL:** <https://www.ruby-forum.com/t/draggable-element-how-to-get-id-of-dragged-element-and-rec/89730>\
**Category:** Rails\
**Created:** [March 22, 2007, 11:32am UTC](https://www.ruby-forum.com/t/draggable-element-how-to-get-id-of-dragged-element-and-rec/89730 "2007-03-22T11:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 22, 2007, 11:32am UTC](https://www.ruby-forum.com/t/draggable-element-how-to-get-id-of-dragged-element-and-rec/89730/1 "2007-03-22T11:32:35Z")

</div>

Hey 🙂

I’m creating a drag-and-drop tree structure using draggable\_element. I  
use this code,

\<%=  
draggable\_element(content\_element\_id, :ghosting=\>true, :revert=\>true)  
%\>

\<%= drop\_receiving\_element(content\_element\_id,  
:accept =\> ‘tree\_item’,  
:complete =\> “$  
(’#{content\_element\_id}\_activity\_indicator’).hide();”,  
:before =\> “$  
(’#{content\_element\_id}_activity\_indicator’).show();",  
:hoverclass =\> ‘hovering’,  
:with =\> "‘child\_id=’ +  
encodeURIComponent(element.id.split(’_’).last())”,  
:url =\> { :action =\> :adopt } ) %\>

This way, I can send the id of the element that is being dragged, to  
the :adopt action in my controller. But I need to know which element  
the dragged element was dropped upon, so it can be adopted by the  
right parent.

Anybody know how I can do that?

Thanks in advance,  
Daniel 🙂

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 22, 2007, 11:48am UTC](https://www.ruby-forum.com/t/draggable-element-how-to-get-id-of-dragged-element-and-rec/89730/2 "2007-03-22T11:48:05Z")

</div>

Ah, silly me 🙂

Just have to add it to the drop\_receiving\_element call in :url!

```
                        :url => { :action

```

=\> :adopt, :parent\_id =\> navigation\_point.id } )%\>

Cheers 🙂
