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.

On 9/26/07, Sharon M. [email protected] wrote:

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 O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com