# Help with drop\_receiving\_element helper

**URL:** <https://www.ruby-forum.com/t/help-with-drop-receiving-element-helper/138808>\
**Category:** Rails\
**Created:** [May 28, 2008, 12:00am UTC](https://www.ruby-forum.com/t/help-with-drop-receiving-element-helper/138808 "2008-05-28T00:00:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 28, 2008, 12:00am UTC](https://www.ruby-forum.com/t/help-with-drop-receiving-element-helper/138808/1 "2008-05-28T00:00:46Z")

</div>

I have an application that has a list of patient names and then a grid  
representing appointment slots (time).

Each patient has a unique ID and draggable\_element tag:

\<%= draggable\_element “#{rx\_ready\_patient.id}”, :revert =\> true %\>

Then every “slot” in my grid is a droppable element:

\<%= drop\_receiving\_element “slot\_#{slot.id}”, :hoverclass =\>  
“hover”,  
:url =\> { :action =\> “add\_appointment” } %\>

Now so far it all works okay - excepting I don’t get a critical piece  
of information – what is the DOM ID of the drop element. When I drag  
and drop I get this in the console:

Processing CalendarController#add\_appointment (for 127.0.0.1 at  
2008-05-27 16:46:46) [POST]  
Session ID: b958c16b06868fdaa74450b07b0dc339  
Parameters:  
{“authenticity\_token”=\>“13ecc13e1b8114add81d985eb2327ea83a61d2fa”,  
“action”=\>“add\_appointment”, “id”=\>“378”, “controller”=\>“calendar”}

The ID is that of the patient I dropped on the slotbox – but which  
slot box?! Anyone know how I would pass both the slotbox ID along  
with the patient ID? I need both to successfully create an  
appointment.

---

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 28, 2008, 12:40am UTC](https://www.ruby-forum.com/t/help-with-drop-receiving-element-helper/138808/2 "2008-05-28T00:40:39Z")

</div>

You need to include the slot receiving id in the remote call, so  
either include it in your url:

:url=\>{:action=\>‘add\_appointment’, :slot\_id=\>slot.id}

or if you want finer control, use the :onDrop callback instead of :url  
(see [GitHub - madrobby/scriptaculous: script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours.](http://github.com/madrobby/scriptaculous/wikis/droppables) for all  
the options)  
and have a javascript function take care of the drop action. e.g.

:onDrop =\> " function(element){update\_slot(‘#{slot.id}’,element)}")

and then your update\_slot function could parse the id from the  
droppable element id,  
and call an Ajax.Request with whatever parameters you want, including  
the slot.id.

or you could just add the slot\_id to the :with option:

:with=\> “‘id=’ + encodeURIComponent(element.id)&slot\_id=#{slot.id}”

---

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 28, 2008, 3:19am UTC](https://www.ruby-forum.com/t/help-with-drop-receiving-element-helper/138808/3 "2008-05-28T03:19:21Z")

</div>

Thanks, I used the first method you explained and that did the trick.  
Weird, because I had though I had tried that approach – oh well.  
It’s working now though, so I’m happy!

Thank you!  
Nicholas
