Sharon Machlis
2007-Sep-26 18:11 UTC
Is there a Rails helper similar to link_to_remote but for a form check box instead of a link?
I''m working on a couple of user input forms -- one data entry, one search -- where I''d like to start off by displaying only top-level categories. Then, if a user checked one of the top-level categories, all the child categories would show for that top-level one. (Displaying all the child categories for every parent would be a bit overwhelming, it''s a large list.) I can see how to do this by making the category name a clickable link, and using link_to_remote, but that''s not an expected UI for a form. I''d rather use a check box, but I''d like to avoid trying to write my own non-Rails-assisted Ajax from scratch if possible. 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson
2007-Sep-26 18:18 UTC
Re: Is there a Rails helper similar to link_to_remote but for a form check box instead of a link?
On 9/26/07, Sharon Machlis <smachlis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m working on a couple of user input forms -- one data entry, one > search -- where I''d like to start off by displaying only top-level > categories. Then, if a user checked one of the top-level categories, > all the child categories would show for that top-level one. > (Displaying all the child categories for every parent would be a bit > overwhelming, it''s a large list.) > > I can see how to do this by making the category name a clickable link, > and using link_to_remote, but that''s not an expected UI for a form. > I''d rather use a check box, but I''d like to avoid trying to write my > own non-Rails-assisted Ajax from scratch if possible.You can use the #remote_function helper that generates the javascript that #link_to_remote uses: <%= check_box_tag :foo, ''1'', params[:foo], :onclick => remote_function(:url => ...) %> -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---