我正在尝试在我的Rails3应用程序中重新创建this table。我相信我已经包含了所有必要的javascript文件,但我一直收到这个错误:
Uncaught TypeError: Cannot read property 'oStdClasses' of undefined
我直接复制了他的HTML和javascript文件,所以我不确定是什么问题。我是jquery/javascript的新手,所以我确信我只是错过了一些愚蠢的东西。任何提示都会很好。
编辑:我猜文件是以错误的顺序加载的,因为当我查看我的控制台时,这是我看到的:
Started GET "/" for 127.0.0.1 at 2012-03-29 11:17:14 -0400
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (18.0ms)
Compiled bootstrap-responsive.css (0ms) (pid 37780)
Compiled bootstrap.css (0ms) (pid 37780)
Compiled docs.css (0ms) (pid 37780)
Compiled home.css (16ms) (pid 37780)
Compiled scaffolds.css (0ms) (pid 37780)
Compiled application.css (33ms) (pid 37780)
Compiled jquery.js (1ms) (pid 37780)
Compiled jquery_ujs.js (0ms) (pid 37780)
***Compiled DT_bootstrap.js (0ms) (pid 37780) #=> Wrong order?
Compiled bootstrap-alert.js (0ms) (pid 37780)
Compiled bootstrap-button.js (0ms) (pid 37780)
Compiled bootstrap-carousel.js (0ms) (pid 37780)
Compiled bootstrap-collapse.js (0ms) (pid 37780)
Compiled bootstrap-dropdown.js (0ms) (pid 37780)
Compiled bootstrap-modal.js (0ms) (pid 37780)
Compiled bootstrap-popover.js (0ms) (pid 37780)
Compiled bootstrap-scrollspy.js (0ms) (pid 37780)
Compiled bootstrap-tab.js (0ms) (pid 37780)
Compiled bootstrap-tooltip.js (2ms) (pid 37780)
Compiled bootstrap-transition.js (0ms) (pid 37780)
Compiled bootstrap-typeahead.js (0ms) (pid 37780)
Compiled google-code-prettify/prettify.js (0ms) (pid 37780)
Compiled home.js (118ms) (pid 37780)
***Compiled jquery-1.7.1.min.js (1ms) (pid 37780)
***Compiled jquery.dataTables.js (6ms) (pid 37780)
***Compiled jquery.dataTables.min.js (0ms) (pid 37780)
Compiled application.js (292ms) (pid 37780)
Completed 200 OK in 574ms (Views: 573.7ms)
我将尝试手动对它们进行重新排序,看看是否会有所不同。
发布于 2012-03-30 01:19:38
我的问题是文件没有按正确的顺序加载。我使用this answer对文件进行了手动重新排序,使其正常工作。
发布于 2013-05-08 00:33:19
如果您正在使用twitter,请确保您的application.js,中同时需要基本数据表JavaScript和jquery-datatable-rails引导变量,例如:
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap
只包含bootstrap JS文件将导致错误。
https://stackoverflow.com/questions/9929101
复制相似问题