public Method

TextHelper.reset_cycle(name = "default")

Resets a cycle so that it starts from the first element the next time it is called. Pass in name to reset a named cycle.

Example

# Alternate CSS classes for even and odd numbers...
@items = [[1,2,3,4], [5,6,3], [3,4,5,6,7,4]]
<table>
<% @items.each do |item| %>
  <tr class="<%= cycle("even", "odd") -%>">
      <% item.each do |value| %>
        <span style="color:<%= cycle("#333", "#666", "#999", :name => "colors") -%>">
          <%= value %>

      <% end %>

      <% reset_cycle("colors") %>

<% end %>
</table>

Source Code

# File action_view/helpers/text_helper.rb, line 419
def reset_cycle(name = "default")
  cycle = get_cycle(name)
  cycle.reset unless cycle.nil?
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.