【发布时间】:2014-03-12 23:13:39
【问题描述】:
我有一个目录页面,列表在索引页面上呈现。
<% @listings.each do |listing| %>
# do some stuff
<% end %>
我为每个列表添加了一个数据切换 - 基本上是一个按钮。
<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>
此数据切换打开一个 STATIC div。 div 是一个带有内容的滑块。
<div id="dr" class="chat-window-wrapper">
我想使用每个按钮将listing.id 传递给一个变量。然后,我可以在整个 div 中使用该 ID。
例如:
带有 ID 的列表:
- 堆栈 - 1
- 溢出-2
- 红宝石 - 3
- 导轨 - 4
- 点击 - 5
假设我单击 id 为 3 的“Ruby”按钮,我希望像这样传递 id。
variable = 3
<div id= <%= variable %> class="chat-window-wrapper">
【问题讨论】:
标签: javascript jquery html ruby-on-rails