0
我在我的rails應用程序中有一個表格,我想用DataTables使它看起來不錯。我正在使用jquery-datatables-rails
寶石。爲什麼DataTables不能在我的rails中工作?
我的部分:
<script type="text/javascript">
$(document).ready(function() {
$('#businesses').dataTable();
});
</script>
<table id="businesses">
<thead>
<tr>
Bunch of headers here...
</tr>
</thead>
<tbody>
<tr>
Lots and lots of code here...
</tr>
</tbody>
</table>
的application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require_tree .
application.css:
*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require dataTables/jquery.dataTables
*= require_tree .
*/
的數據表文件是在application.js
和application.css
正確引用爲好。
謝謝!
確保你只用
我只按照您的說法使用
瀏覽器無法找到該頁面中的datatable.js文件。請在這裏添加application.js的相關代碼 – Pheonix 2012-07-12 18:18:29
回答
你應該把你的js代碼移到你的application.js文件中。
所以,你html.erb內部沒有腳本標記,做的JavaScript部分,你應該有這樣的一個application.js中:
來源
2015-01-01 21:57:58 user3299737
相關問題