Q:

Rails 4 - how to get a  click to display a partial view in another ?

I have a site where I want categories to be displayed at the top of the page as drop down buttons. Once you click on the the button, it will show a list of items. Upon clicking on the item (<li> element) the other items related to it should appear in a <div> below it. Right now it appears with correct results but in the wrong location... right under the <li>.  This is the line of code I'm using to display the partial: <li><%= d %>&nbsp;<span class="badge"><%= @c_id_obj.count %></span><%= link_to render(:partial => 'show', locals: {item: @item_to_c}) %></li>
I need the variable declared in the locals option to pass through into the partial view as well. 
How can I get the partial to show up in div#display based on what <li> I select? 
If I put the rendering code inside div#display then it won't get the right variable, so it has to somehow use the right variable based on what <li> I select. 
Here's the code I have so far....
index.html.erb: 
<%= link_to items_path, class: 'btn btn-default btn-lg' do %>
   See all <span class="badge"><%= @items.count %></span>
<% end %>

<div class="btn-group" role="group">
    <button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown">Food <span class="badge">
<%= @food.count %></span>&nbsp;<span class="caret"</span>
</button>
      <ul class="dropdown-menu">
        <% @food.each do |x| %>
        <% q = /#{x}/i %>
        <% @food_id = Array.new %>
        <% @food_id_obj = @items.any_of(:food => q).only(:id) %>
        <% @food_id_obj.each {|i| @food_id << i._id } %>
        <% @item_to_food = @items.any_of(:_id.in => @food_id) %>
            <li><%= x %>&nbsp;<span class="badge"><%= @food_id_obj.count %></span><%= link_to render(:partial => 'show', locals: {item: @item_to_food}) %></li>

        <% end %>
     </ul>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown">Clothing <span class="badge">
<%= @clothing.count %></span>&nbsp;<span class="caret"</span>
</button>
      <ul class="dropdown-menu">
        <% @clothing.each do |d| %>
        <% g = /#{d}/i %>
        <% @c_id = Array.new %>
        <% @c_id_obj = @items.any_of(:Clothing => g).only(:id) %>
        <% @c_id_obj.each {|u| @dt_id << u._id } %>
        <% @item_to_c = @items.any_of(:_id.in => @c_id) %>
            <li><%= d %>&nbsp;<span class="badge"><%= @c_id_obj.count %></span><%= link_to render(:partial => 'show', locals: {item: @item_to_c}) %></li>
        <% end %>
     </ul>
</div>

<br/><br/>

<div class="pull right" id="display"></div>

_show.html.erb:
  <table class="table-hover table-bordered">
    <thead>
      <tr>
        <th>Food name</th>
        <th>Clothing name</th>

        <th colspan="3">Options</th>^M
      </tr>
    </thead>

    <tbody>
      <% item.each do |i| %>
        <tr>
        <td><%= i.food %></td>
        <td><% i.clothing.each do |u| %>
           <ul>
             <li><%= u %></li>
           </ul>
           <% end %>
        </td>

A:

ended up having to make a method in the controller that called a javascript file and this javascript called the parital. Had to pass the variables through the rails path. used this as a reference: 
https://coderwall.com/p/kqb3xq/rails-4-how-to-partials-ajax-dead-easy

