dimanche 19 avril 2015

Displaying a modal for one entry in a .each loop - Rails / Bootstrap

I'd like a link to open a modal displaying the clicked object (word.title), displayed in an each loop. Right now it opens the modal but then displays it again for every item in the loop.

<h1>Glossary of words</h1>
<p>Pagination at 25</p>

<table class="table table-hover">
<th>Word Type</th>
<% @words.each do |word| %>
<th scope="row">
<a href="#" data-toggle="modal" data-target=".bs-example-modal-sm">
<%= word.title %>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<%= word.title %>
<td><%= word.title %></td>
<td><%= word.definition %></td>
<td><%= word.word_type %></td>

<% end %>

// Word Modal

Aucun commentaire:

Enregistrer un commentaire