【发布时间】:2020-03-26 16:26:28
【问题描述】:
我正在尝试使用 Rails 6 和 Bootstrap 4 创建一个可点击的表格行(不确定这是否是 Bootstrap 问题)。使用以下代码无法“点击”这些行:
index.erb.html:
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">PPU</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
<% @accounts.each do |account| %>
<tr>
<% link_to "Show", account_path(account) %>
<th scope"row"><%= account.name %></th>
<td><%= account.ppu %></td>
<td><%= account.notes %></td>
</tr>
<% end %>
</tbody>
</thead>
</div>
表格渲染良好,但没有 DOM 点击。
更新我想出了如何使行中的每个属性都可以点击,如下所示:
<th scope"row"><%= link_to account.name, account_path(account) %></th>
现在我想让整行可点击,这需要不同的方法。
【问题讨论】:
-
需要用JS让整行可点击
标签: ruby-on-rails onclick link-to ruby-on-rails-6