首页 > 解决方案 > 数据表功能不只显示表中的数据,而是在撇号中显示

问题描述

我想在 apostropheCMS 中添加 Datatable,但它的功能没有显示。我在 index.html 中编写了数据表的代码,并在头文件中添加了数据表的 CDN 和函数。但它不起作用。只显示数据,不显示表格。

应用程序/lib/模块/.../views/index.html

/app/view/header.html

索引.html

{% block main %}
    <main>
       <table id="example" class="display cell-border" style="width:100%">
            <thead>
                <tr>
                    <th>Column 1</th>
                    <th>Column 2</th>
                    <th>Column 3</th>
                    <th>Column 4</th>
                    <th>Column 5</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                  <td>Tiger Nixon</td>
                  <td>System Architect</td>
                  <td>Edinburgh</td>
                  <td>61</td>
                  <td>2011/04/25</td>
                  <td>$320,800</td>
                </tr>
            </tbody>
          </table>
    </main>
{% endblock %}

header.html

<header>
<script>
          $(document).ready(function() { alert();
                var table = $('#example').DataTable( {
                  "pagingType": "full_numbers"
               } );
              $('#example tbody').on( 'click', 'tr', function () {
                  if ( $(this).hasClass('selected') ) {
                      $(this).removeClass('selected');
                  }
                  else {
                      table.$('tr.selected').removeClass('selected');
                      $(this).addClass('selected');
                  }
              } );


          } );
       </script>
</header>

标签: javascriptjqueryapostrophe-cms

解决方案


推荐阅读