title: Passing data from a loop, into a partial on click, in Rails
body: <p>I have a list of items at at <code>category/1</code> which are being displayed in a loop and I have a modal which I’m rendering at the bottom of the page with <code>&lt;%= render "category/update_item_modal" data: {???} %&gt;</code></p>
  
  <p>I'm trying to pass data to a modal which will pop up when the button below is clicked:-</p>
  
  <p><code>&lt;a href="#" data-toggle="modal" data-target="#updateItemModal"&gt;&lt;button class="btn btn-primary btn-sm"&gt;Edit Title&lt;/button&gt;&lt;/a&gt;</code></p>
  
  <p>The modal itself:-</p>
  
  <pre><code>&lt;div class="modal fade" id="updateItemModal" tabindex="-1" role="dialog" aria-labelledby="updateItemModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h5 class="modal-title" id="updateItemModalLabel"&gt;Change Item&lt;/h5&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
            &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;!-- UPDATE TITLE HERE? --&gt;
          &lt;%= item.title??? %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So, when the Edit Title button is clicked on a specific item, I have to pass my the correct item into my <code>data</code> label and render stuff from that title in the modal.  What's the best way to do this given my modal is outside of the loop? Do I need some JS here?</p>
  
  <p>P.S. In my controller I have access to <code>@category</code> which has around 100 items, i.e. I can't get the specific item from the controller since there are many on the page.</p>