我想在apostropheCMS中添加数据表,但未显示其功能。我在index.html中编写了datatable的代码,并在头文件中添加了datatables的CDN和函数。但它不起作用。仅显示数据,不显示表。
app / lib / module /.../ views / index.html
/app/view/header.html
index.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>