Dynamically name class on rails view? -
i have each loop , want use index var name dynamically have tried didn't work.
<% (0..4).each |i| %> <div id="item-<%= #{i} %>" class="hold-button">
try this:
<% (0..4).each |i| %> <div id="item-<%= "#{i}" %>" class="hold-button"> <% end %>
or
<% (0..4).each |i| %> <div id="item-<%= %>" class="hold-button"> <% end %>
remember: #{} used embedded variable strings. that's why code doesn't work.
Comments
Post a Comment