javascript - 数据表功能不只显示表中的数据,而是在撇号中显示
问题描述
我想在 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>
解决方案
推荐阅读
- python - 使用 append() 和 DataFrame.columnName 添加熊猫列值,但数据框中没有更新列值
- javascript - 如何从 firestore 获取 ID 到对象数组中?
- python - python中循环中的多重求和
- python - 使用 signals.py 更新模型字段 ( SearchVector )
- java - Android - CustomApplication 中的类转换异常
- join - 2个表之间的不同连接
- javascript - 如何从函数中多次产生价值?
- django - Django,如何在不创建新文件/django_session 行的情况下测试迁移
- node.js - “模板启动”命令在 ./assets/js/theme/account.js 中显示错误 模块构建失败
- c# - 在 unity3d 中从脚本创建文本文件有延迟/错误