Hi All
I have a form that has two select/list form elements. I''m
using
ajax (rjs, partials, and observe_field) to enable a user to move items
from one list/select to another list/select. When the user is
satisfied
with the items they''ve collected in the ''destination''
list/select
box, they hit a ''Submit'' button.
My question is how do I pass along the contents dynamically
added to the ''destination list/select'' box along with the
Submit
request - without the user having to select items in the ''destination
list/select'' box. The items the user ''wants'' have
already been
selected by being put in this ''destination list/select'' box -
so they
shouldn''t have to select them again.
Any help is greatly appreciated
Thanks
Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Let''s say the div now looks like:
<div>
<li id="destination_12">...</li>
<li id="destination_11">...</li>
<li id="destination_19">...</li>
</div>
Use Prototype to collect the id''s of your destinations into an array.
Then, but that into a hidden field in your form:
"$(''hidden_field_id'').value =
destinations_array.join('','')"
Then, in your controller, you can:
destination_ids = params[:...][:hidden_field_id].split('','')
destinations = destination_ids.map{|d_id| Destination.find(d_id) }
#or use something like: Destination.find(:all, :conditions=>[''id in
?'',
destination_ids ]
#but be sure to sterilize it
Hopefully that provides a starting point for you.
Mike
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---