0

我一直在努力完成这项工作,但似乎找不到解决方案:

我有一个表格,并且我对 Datatables 进行了基本初始化,一切似乎都可以正常工作,但是一旦激活响应式,详细信息按钮将不起作用,如果我单击它,它会变红并带有 - 符号,但详细信息不会出现.

这是我的桌子:

<table id="tabla" class="display dt-responsive no-wrap" width="100%">
  <thead>
    <tr>
      <th>Profesor</th>
      <th>Materia</th>
      <th>Seccion</th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @profesors.each do |profesor| %>
      <tr>
        <td><%= profesor.profesor %></td>
        <td><%= profesor.materia %></td>
        <td><%= profesor.seccion %></td>
        <td><%= link_to 'Show', profesor %></td>
        <td><%= link_to 'Edit', edit_profesor_path(profesor) %></td>
        <td><%= link_to 'Destroy', profesor, method: :delete, data: { confirm: 'Are you sure?' } %></td>
        <td><%= link_to 'Alumnos', alumnos_path("prof" => profesor) %></td>
      </tr>
    <% end %>
  </tbody>
</table>

这是我的 JS

$('#tabla').DataTable({
    responsive: true
});
4

1 回答 1

0

如果您使用引导程序,请尝试<table>使用<div class="table-responsive"> 链接包装

一些喜欢:

<div class="table-responsive">
  <table id="tabla" class="display dt-responsive no-wrap" width="100%">
    <thead>
      <tr>
        <th>Profesor</th>
        <th>Materia</th>
        <th>Seccion</th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @profesors.each do |profesor| %>
        <tr>
          <td><%= profesor.profesor %></td>
          <td><%= profesor.materia %></td>
          <td><%= profesor.seccion %></td>
          <td><%= link_to 'Show', profesor %></td>
          <td><%= link_to 'Edit', edit_profesor_path(profesor) %></td>
          <td><%= link_to 'Destroy', profesor, method: :delete, data: { confirm: 'Are you sure?' } %></td>
          <td><%= link_to 'Alumnos', alumnos_path("prof" => profesor) %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
</div>
于 2017-03-08T13:03:59.107 回答