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:
1. call a method that will make various database updates
2. change it''s own label from "Complete?" to
"Completed"
3. 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 Fauser''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 = {
}
) %>
<div id="OTcomplete"><span
class="label">Completed?</span></div>
<%= end_form_tag %>
FROM THE RJS "OTcomplete"
page.insert_html :bottom, ''OTcomplete'', :partial =>
''OTComplete''
page.visual_effect :highlight, ''OTcomplete''
FROM THE PARTIAL "_OTComplete"
<span class="label"><b>Complete</b></span>
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:
1. implement the strikethrough of the text name
2. 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
--
Posted via http://www.ruby-forum.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
-~----------~----~----~----~------~----~------~--~---
Mike Dershowitz wrote:> > I have a bit of a checkbox connundrum I > need some help with.I can see a couple of things that are going to be problems. But I can''t tell from your description exactly what problem you''re having right now. What is your code doing / not doing that you need help with?> I have a page that displays a list of tasks. These > tasks have a bunch of information on them.> FROM THE VIEW: > <%= form_remote_tag :url => { :action => ''OTcomplete'' },: :html => {:id => ''OTcomplete'' } %>> <%= check_box_tag ("OTcomplete", nil, checked = false, > options = { } ) %> > <div id="OTcomplete"><span class="label">Completed?</span></div> > <%= end_form_tag %>You''ve given both the form and the div within it the same id. That''s bad. Each DOM element needs to have a unique id. Ajax depends on it to find the element to update. If I understand what you''ve said, you''re generating a form element for each item. If that''s right, then the problem is compounding . First step is to take the rendered page source and validate it at http://validator.w3.org/ . If the xhtml doesn''t validate without errors (warnings are ok), then you''re going to have problems. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---