Hi:
I have a bit of a checkbox connundrum I need some help with.
I have a page that displays a list of tasks. These tasks have a bunch
of information on
them. I want to do a fairly normal operation with a checkbox. the
checkbox indicates when
the task is complete. The checkbox needs to do the following things:
- call a method that will make various database updates
- change it’s own label from “Complete?” to “Completed”
- Change the text of the task from normal to strikethrough
It looks like I need to use form_remote_tag and make an AJAX call so all
of this can be
handled in real-time. But he example from Cody F.'s book don’t seem
to translate for
me. This is how far I’ve gotten:
FROM THE VIEW:
<%= form_remote_tag :url => { :action => ‘OTcomplete’ }, :html => {
:id =>
‘OTcomplete’ } %>
<%= check_box_tag (“OTcomplete”, nil, checked = false, options = {
}
) %>
<%= end_form_tag %>
FROM THE RJS “OTcomplete”
page.insert_html :bottom, ‘OTcomplete’, :partial => ‘OTComplete’
page.visual_effect :highlight, ‘OTcomplete’
FROM THE PARTIAL “_OTComplete”
Complete
FROM THE MODEL
The model has some code in it to make a DB insert when the user clicks
the checkbox
Here’s what I didn’t do yet:
- implement the strikethrough of the text name
- figure out how to reverse this process if the user clicks a checkbox
that has been
changed to “Complete”
Thank you very much in advance for your help!
Mike