I need a table with selectable rows (there is a check box in every row). All selected rows should be displayed with different style than rows which are not selected. I implemented this behavior by assigning the css-defined class to <tr> tag <tr id=<%="msgrow_#{m.id}"%> class="unchecked_msg"> and toggling the class whenever checkbox is clicked. <%= check_box_tag("checked_messages[]", object.id, false, :class=>"selectable_msg", :align=>"top", :onchange => "$ (''msgrow_#{object.id}'').toggleClassName(''checked_msg'', ''unchecked_msg'');") %> It works fine until user refreshes page. After the refresh checkbox is still checked, but the class of the row is reset to "unchecked_msg". Anyone has an idea how to survive page refresh? thanks, Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
only way: make an ajax call, whenever the checkbox is clicked. in the backend store the new value in the session or database and use this information to rebuild the whole page for a refresh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sun, Sep 21, 2008 at 10:23 AM, AdamT <tretkow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I need a table with selectable rows (there is a check box in every > row). All selected rows should be displayed with different style than > rows which are not selected. > I implemented this behavior by assigning the css-defined class to <tr> > tag > > <tr id=<%="msgrow_#{m.id}"%> class="unchecked_msg"> > > and toggling the class whenever checkbox is clicked. > > <%= check_box_tag("checked_messages[]", object.id, > false, :class=>"selectable_msg", :align=>"top", :onchange => "$ > (''msgrow_#{object.id}'').toggleClassName(''checked_msg'', > ''unchecked_msg'');") %> > > It works fine until user refreshes page. After the refresh checkbox is > still checked, but the class of the row is reset to "unchecked_msg". > Anyone has an idea how to survive page refresh?Instead of hard-coding the classes write a dom:loaded observer in JavaScript that iterates over the rows and assigns the class as needed. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---