【发布时间】:2014-04-21 12:06:35
【问题描述】:
我正在尝试使用数据表插件,但在调用函数 dataTable() 时出现错误。 我的代码如下所示:
@Scripts.Render("~/Scripts/DataTables-1.9.4/media/js/jquery.js")
@Scripts.Render("~/Scripts/DataTables-1.9.4/media/js/jquery.dataTables.js")
<script type="text/javascript">
$(function () {
$('#tableID').dataTable();
});
</script>
<table class="table table-striped table-hover table-bordered" id="tableID">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<td>Row 2</td>
<td>Row 2</td>
</tr>
</tbody>
</table>
当我运行它时,我可以在 Firebug 中看到一个错误:
TypeError: $(...).dataTable is not a function
$('#tableID').dataTable();
在 Firebug 中我可以看到包含 jquery.dataTables.js 文件,但函数 dataTable() 不起作用。
【问题讨论】:
-
你的js文件里有没有叫
dataTable()的函数?
标签: javascript jquery datatable