我试图在Rails应用程序中运行可数据,但这对我来说行不通。
在我的档案里:
gem 'jquery-datatables-rails'
gem 'jquery-rails'
gem 'bootstrap-sass'用于检查是否存在的Shell命令:
gem list | grep -i datatables
jquery-datatables-rails (1.12.2)application.css:
*= require dataTables/jquery.dataTablesapplication.js
//= require dataTables/jquery.dataTablesclients.js
jQuery ->
$('#clients').dataTable()init数据应该对吗?
Firebug错误:
TypeError: $(...).dataTable is not a function
$('#clients').dataTable();或者:
ReferenceError: jQuery is not defined
$('#clients').dataTable({有什么想法吗?耽误您时间,实在对不起。
发布于 2014-02-08 01:46:42
我最近也收到了类似的错误消息。首先,您在表标签中设置了id吗?你的桌子上有头和头的标签吗?
<table id='clients'>
<thead>
<tr>
<th>...</th>
</tr>
</thead>
<tbody>
<% @clients.each do |client| %>
<tr>
<td>...</td>
</tr>
</tbody>
</table>第二:您使用的是->符号,即函数关键字的CoffeeScript替换,此外CoffeeScript是选项卡敏感的。确保您的CoffeeScript文件名以.coffee结尾。我会尝试使用选项卡并更改文件名。
clients.js.coffee
jQuery ->
$('#clients').dataTable()通过这些更改,您可能会以DataTable的工作而结束。
https://stackoverflow.com/questions/21129357
复制相似问题