check_box_tag remote_function

I have a collection of check_box_tags that look like the following:

<% for item in @items %>
<%= check_box_tag "item[item_ids][]",, false, {:onchange =>
remote_function(:url => update_items_path, :with => "'items=' +
escape(value) "} %>
<%= %>
<% end %>

My question is, how do I send all of the current checkbox values
(item[item_ids][]) in the onchange? Currently, I am only getting the
value of the changed checkbox (ie: items=2), but I need to know which
other checkboxes are checked.


Is there a reason not to manage ONLY the change, rather than trying to
manage the entire collection on each change? Seems like it'd be more
efficient to take the id/value that you receive and either to a
x.items << Item.find(id) or x.items.delete Item.find(id). Regardless,
it sounds like you'd want either an observe_form (sees all the changes
and submits the entire form) or you could wrap up the check boxes in
some container (fieldset, div, etc), give the container a name, and
then use:

remote_function(:url=>..., :submit=>'container_id')

That will serialize the values of all the input elements in the
container. Note that you'll only receive the ids of check boxes that
are checked.

Thanks for the response. Definitely some good options. I think I will
give the :submit => 'container_id' a shot, as it seems most inline
with what i'm trying to do.