# Ajaxing Checkboxes

**URL:** <https://www.ruby-forum.com/t/ajaxing-checkboxes/124452>\
**Category:** Rails\
**Created:** [December 28, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/ajaxing-checkboxes/124452 "2007-12-28T20:21:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@ngm](https://www.ruby-forum.com/u/ngm)\
**Post date:** [December 28, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/ajaxing-checkboxes/124452/1 "2007-12-28T20:21:39Z")

</div>

Hi,

I’ve the following call to link\_to\_remote:

\<% @calendars.each do |c| %\>  
\<%= link\_to\_remote 'dont show '+c.name, :url =\> { :action =\>  
‘update\_calendar’, :id =\> c.id } %\>

It shows a list with calendars.

When the user presses on the link it hides that calendar (given the id).  
Fine.

But now it would be nice to replace the link by a checkbox. And the  
update\_calendar method would read the params[:id] and the  
params[:selected] in order to show or hide a given calendar.

The problem is, I don’t have a “check\_box\_to\_remote” method.

Can you give me some ideas on this? Or it’s not possible?

Thanks

---

<div class="post-metadata">

**Author:** ![ngm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@ngm](https://www.ruby-forum.com/u/ngm)\
**Post date:** [December 29, 2007, 1:48am UTC](https://www.ruby-forum.com/t/ajaxing-checkboxes/124452/2 "2007-12-29T01:48:54Z")

</div>

> The problem is, I don’t have a “check\_box\_to\_remote” method.
> 
> Can you give me some ideas on this? Or it’s not possible?

if it really just hides the calendar in html and doesn’t do any  
database stuff serverside you can do it like:

 # calendar stuff here

\<%=f.check\_box, :onclick =\> “$(‘calendar\_#{calendar.id}’).toggle()” %\>

as i mentioned, this only makes sense if you dont need any serverside  
action here.

Pascal
