use*_*688 5 javascript datatable jquery
我正在尝试使用datatables插件,但在调用函数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>
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我可以在Firebug中看到错误:
TypeError: $(...).dataTable is not a function
$('#tableID').dataTable();
Run Code Online (Sandbox Code Playgroud)
在Firebug中我可以看到包含的jquery.dataTables.js文件,但函数dataTable()不起作用.
小智 9
对我来说工作移动定义开箱即用
代替
<script type="text/javascript">
$(function () {
$('#tableID').dataTable();
});
</script>
Run Code Online (Sandbox Code Playgroud)
我用
<script type="text/javascript">
$('#tableID').dataTable();
</script>
Run Code Online (Sandbox Code Playgroud)
它完美无缺.
在我的情况下:
我包括在内
@Scripts.Render("~/bundles/jquery")
Run Code Online (Sandbox Code Playgroud)
在页面中两次:在标题和之前</body>
当我删除它们时,问题已经消失
| 归档时间: |
|
| 查看次数: |
21019 次 |
| 最近记录: |