The datatables-rails
gem packages the jQuery DataTables assets for easy inclusion in an Rails >= 3.1 application using the asset pipeline.
The MAJOR, MINOR and PATCH version numbers of this gem will follow the version numbers of jQuery DataTables. The fourth version number will be increased for changes unrelated to the assets themselves.
For an alternative solution, feel free to take a look at the jquery-datatables-rails gem.
To use this gem you need to include jQuery in your applications's javascript. To do so you may use the jquery-rails gem.
Add this line to your application's Gemfile
:
gem 'datatables-rails', '~> 1.10.7.0'
And then execute:
$ bundle install
Include the JavaScript in your app/assets/javascripts/application.js
:
//= require datatables/jquery_datatables
Make sure you add the line after the inclusion of jQuery ( //= require jquery
).
Include the stylesheet in your app/assets/stylesheets/application.css
:
*= require datatables/jquery_datatables
Where needed in your JavaScripts, initialize your DataTables:
$(document).ready(function() {
$("#mytable").dataTable();
});
- Fork it
- Commit your changes (
git commit -am 'My Changes'
) - Push your changes (
git push origin
) - Create a new Pull Request