我有 DataTables 在 Rails 3.2.13 应用程序上工作。这有效
$(document).ready( function () {
$('#products').dataTable();
} );
但是,当我尝试添加 TableTools 插件时,添加“sDom”参数时 DataTables 不再起作用:
$(document).ready( function () {
$('#products').dataTable({
"sDom": 'T<"clear">lfrtip'
});
} );
我添加了这些宝石:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :production do
gem 'pg', '0.12.2'
end
这是css文件:
*= require_self
*= require dataTables/jquery.dataTables
*= require dataTables/extras/TableTools
*= require dataTables/extras/TableTools_JUI
*= require_tree .
*/
下面是js文件:
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require dataTables/extras/TableTools
//= require_tree .
更新:似乎有关于如何添加 TableTools 的更新。你可以在这里找到更新: https ://github.com/rweng/jquery-datatables-rails/pull/28
基本上我必须更新 application.js 文件以包含 ZeroClipboard。(如果您使用 JQueryUI,您还需要一些其他文件)
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require dataTables/extras/TableTools
//= require dataTables/extras/ZeroClipboard