The datatablesassets-rails
gem packages the jQuery DataTables assets for easy inclusion
in an Rails application using assets pipeline.
DataTables version used in the project: 1.10.12
Installation
To use this gem you need jQuery in your application javascript.
Add this line to your application's Gemfile:
gem 'datatablesassets-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install datatablesassets-rails
Usage
JavaScript
Include the javascript part:
For Coffeescript
#= require datatables/jquery.dataTables
For JavaScript
//= require datatables/jquery.dataTables
Make sure you add the line after the inclusion of jQuery
Stylesheets
Include the style part:
@import "datatables/jquery.dataTables";
Initialize
Example for Bootsrtap
app/assets/javascript/applicataion.js
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require datatables/jquery.dataTables
//= require datatables/dataTables.bootstrap
$(document).ready(function() {
$('table').DataTable();
});
app/assets/stylesheets/style.scss
@import "bootstrap-sprockets";
@import "datatables/dataTables.bootstrap";
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.