This Gem is unmaintained and deprecated. Please use Webpacker or a similar solution instead.
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.
Installation
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
Usage
JavaScripts
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
).
Stylesheets
Include the stylesheet in your app/assets/stylesheets/application.css
:
*= require datatables/jquery_datatables
Initialization
Where needed in your JavaScripts, initialize your DataTables:
$(document).ready(function() {
$("#mytable").dataTable();
});
Contributing
- Fork it
- Commit your changes (
git commit -am 'My Changes'
) - Push your changes (
git push origin
) - Create a new Pull Request