i am using .each
in rails project_site
in index#action with foundation model reveal on each row but
issue is model reveal just shows id of last project_site
in each model-reveal. i want reveal should reveal id of current project_site
.
<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site| %>
<tr>
<td><%= project_site.user.name %></td>
<td>
<div class="full reveal" id="exampleModal1" data-reveal>
<%= project_site.id %>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<p><button class="button small warning button-margin-top fi-eye" data-open="exampleModal1"> View</button></p>
</td>
</tr>
<% end %>
Each modal has the same id, so the last one always wins. Change the view so each row's modal has its own id, and the open button calls the proper one...
<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site| %>
<tr>
<td><%= project_site.user.name %></td>
<td>
<% site_modal_id = "site_modal_#{project_site.id}" %>
<div class="full reveal" id="<%= site_modal_id %>" data-reveal>
<%= project_site.id %>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<p><button class="button small warning button-margin-top fi-eye" data-open="<%= site_modal_id %>"> View</button></p>
</td>
</tr>
<% end %>
Note that if you have a lot of project sites your page is going to slow down and it would be better to have a single modal where you pass in the data on the cick.