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 received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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}"
On May 27, 5:00 pm, ncancelliere
<ncancelli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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 received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 On May 27, 5:39 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > (seehttp://github.com/madrobby/scriptaculous/wikis/droppablesfor 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}" > > On May 27, 5:00 pm, ncancelliere <ncancelli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---