On Wed, Sep 30, 2009 at 1:30 PM, Shaun Pearl <[email protected]> wrote: > > First off, I'm fairly new to ruby on rails so this may appear simple but > I'm just learning the ropes :) > > So I have a simple blog app where a post has many comments. The 'show' > view for posts renders a partial for each comment the post has. The css > class of the containing div element is cycled using cycle(). The partial > code is, > > <% div_for(comment, :class => cycle("blue","white")) do %> > <p><span class='commentdate'><%= > comment.created_at.strftime("#{comment.created_at.day.ordinalize} %b > %Y") %></span> > <strong><%= h(comment.name) %></strong><span class='grey'> > says:</span></p> > <p><%= h(comment.content) %></p> > <% end %> > > > This works fine when you first render the page... however when you add a > new comment via ajax it inserts an additional partial... but the cycle > seems to have reset itself and the css class will always be blue. Is > there a means to make sure that the cycle continues on from the previous > rendering of the partial? Or perhaps a more elegant way of doing it > altogether? > > Thanks.
I often use javascript to set the class names of the rows after the page renders. Here are many examples: http://blog.jquery.com/2006/10/18/zebra-table-showdown/ -- Greg Donald http://destiney.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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

