Help with drop_receiving_element helper

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.

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 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}"

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