表中可点击行的错误(Rails 4)

时间:2015-09-09 13:03:48

标签: html css ruby-on-rails

我有一个链接到客户展示页面的表

_table.html.erb

<table class="table table-striped table-bordered table-hover table-condensed">
  <thead>
    <tr>
      <th width="50"><%= sort_link @q, :id, "ID"%></th>
      <th width="50"><%= sort_link @q, :health_status_ok, "Status"%></th>
      <th width="50"><%= sort_link @q, :first_name, "First Name"%></th>
      <th width="50"><%= sort_link @q, :last_name, "Last Name"%></th>
      <th>Tickets Enabled</th>
      <th>Notes</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @customers.each do |customer| %>
      <a href="<%= customer_path(customer) %> ">
        <tr data-link="<%= customer_path(customer) %>">
          <td>&nbsp;&nbsp;&nbsp;<%= customer.id %></td>
          <td>&nbsp;&nbsp;<i class="<%= status_code_css(customer.health_status_ok)%>"></i></td>
          <td><%= customer.first_name  %></td>
          <td><%= customer.last_name  %></td>
          <%= ( render 'customers/auto_ticket_enable', customer: customer ) if AUTHORIZED_USERS.include?(session[:current_user_login])%>
          <td><%= customer.notes.nil? ? "" : customer.notes  %></td>
          <td><%= link_to "View", customer_path(customer), class: 'btn center-block' %></td>
        </tr>
      </a>
    <% end %>
  </tbody>
</table>

当页面呈现时,该行不可点击。 源看起来像一个实例。

...
<tbody>
      <a href="/customers/11 ">
        <tr data-link="/customers/11">
          <td>&nbsp;&nbsp;&nbsp;11</td>
          <td>&nbsp;&nbsp;<i class="fa fa-check-circle fa-2x status-ok"></i></td>
          <td>Some</td>
          <td>Dude</td>
            <td style="color:green"><strong>Enabled</strong></td>

          <td>123 Anyplace you want. </td>
          <td><a class="btn center-block" href="/customers/11">View</a></td>
        </tr>
      </a>
...

如何使整行成为可点击链接。我错过了什么?

1 个答案:

答案 0 :(得分:1)

我不相信你可以将<tr>放在<a>标记内。

我看到你正在使用Bootstrap。请参阅this StackOverflow post了解如何使用引导程序附带的jQuery使表行可单击。