I have a directory page where the listings are rendered on the index page.
<% @listings.each do |listing| %>
# do some stuff
<% end %>
I've added a data-toggle to each listing - basically a button.
<a id="chat-menu-toggle" href="#dr" class="chat-menu-toggle" >
<div class="iconset top-chat-dark ">
<span class="badge badge-important hide" id="chat-message-count">1
</span>
</div>
</a>
This data-toggle opens a STATIC div. The div is a slider with content.
<div id="dr" class="chat-window-wrapper">
I want to use each button to pass the listing.id to a variable. Then, I can use that ID throughout the div.
For example:
Listing with ID:
- Stack - 1
- Overflow -2
- Ruby - 3
- Rails - 4
- Onclick - 5
Let's say I click the button for "Ruby" which has an id of 3, I want the id to be passed around like so.
variable = 3
<div id= <%= variable %> class="chat-window-wrapper">