I have a list of items. each item will have a checkbox next to it. I have a series of commands (in a sidebar div) that should perform an operation on the selected items in the list. I know how to encapsulate that list with a form and then perform the operations on the checked items, but my question is, how do you (and can you) gather up the checked items on the click of the link and submit them to a controller for processing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This may not be much help, but you can pass multiple arguments by using the link helper (or any helper for that matter): <%= link_to ''Submit'', :action => ''my_action'', :id => @user.id, :name => @user.name %> But I don''t know how to do this using checkboxes or text fields that are not wrapped in form tags. You might try passing the value of the id that you gave to your checkboxes and then in your method that is called by the :action if they are checked or not. -- 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 -~----------~----~----~----~------~----~------~--~---
Shandy Nantz wrote:> > But I don''t know how to do this using checkboxes or text fields that are > not wrapped in form tags. You might try passing the value of the id that > you gave to your checkboxes and then in your method that is called by > the :action if they are checked or not.This is a neat trick: (ajax-version) link_to_remote(''submit'', :url => {:action => ''blabla'', :id => ''optional''}, :submit => "id_of_element_around_your_checkboxes") The important part is the :submit option ofcourse, just wrap the elements you want to submit in a <div> (or whatever) and everything in it will be posted as if it was in a form. Very usefull for posting rows of a table, because you can''t put a form around a complete row. Or for posting something that''s inside a form (forms in forms are not allowed) Regards, Stijn -- 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 -~----------~----~----~----~------~----~------~--~---
Sounds like a great solution. I will try it, thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 7/19/07, Stijn Pint <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Shandy Nantz wrote: > > > > But I don''t know how to do this using checkboxes or text fields that are > > not wrapped in form tags. You might try passing the value of the id that > > you gave to your checkboxes and then in your method that is called by > > the :action if they are checked or not. > > This is a neat trick: (ajax-version) > > link_to_remote(''submit'', :url => {:action => ''blabla'', :id => > ''optional''}, :submit => "id_of_element_around_your_checkboxes") > > The important part is the :submit option ofcourse, just wrap the > elements you want to submit in a <div> (or whatever) and everything in > it will be posted as if it was in a form. > Very usefull for posting rows of a table, because you can''t put a form > around a complete row. Or for posting something that''s inside a form > (forms in forms are not allowed)that is a great tip, Stijn! A shame I didn''t see your message yesterday, I really could''ve used it! Was trying to submit a form using link_to_remote and :with => Form.serialize(...) but I kept running into difficulty.. This works perfectly, thanks! Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Stijn Pint wrote:> Shandy Nantz wrote: >> >> But I don''t know how to do this using checkboxes or text fields that are >> not wrapped in form tags. You might try passing the value of the id that >> you gave to your checkboxes and then in your method that is called by >> the :action if they are checked or not. > > This is a neat trick: (ajax-version) > > link_to_remote(''submit'', :url => {:action => ''blabla'', :id => > ''optional''}, :submit => "id_of_element_around_your_checkboxes") > > The important part is the :submit option ofcourse, just wrap the > elements you want to submit in a <div> (or whatever) and everything in > it will be posted as if it was in a form. > Very usefull for posting rows of a table, because you can''t put a form > around a complete row. Or for posting something that''s inside a form > (forms in forms are not allowed) > > Regards, > > StijnHey, where were you about 2 1/2 weeks ago? I got to admit, this sounds like a really good idea. I might have to go back and change things in my forms. Thanks Stijn ~S -- 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 -~----------~----~----~----~------~----~------~--~---