
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Jquery datatables assets pipeline :: sprockets
Include jQuery DataTables in your asset pipeline with ease using jquery-datatables gem.
Rails 6.0+ Since Webpacker the default JavaScript compiler for Rails 6. you can install via yarn.
see this official pages for details.
However, if your app still using javascript with sprockets, this gem is still good to go.
Rails 5.1+
The Rails JavaScript helpers has been rewritten in a new gem called rails-ujs and they use vanilla JavaScript, so jQuery is not a dependency of Rails anymore. Since Jquery datatables relies on it, install it with bin/yarn add jquery
or via gem 'jquery-rails'
and add //= require jquery
to application.js
.
NOTE: Ensure that the sass-rails
gem is presented in your Gemfile.
Add this line to your application's Gemfile
:
gem 'jquery-datatables'
And then execute:
$ bundle install
rails g jquery:datatables:install
or if you using css framework
rails g jquery:datatables:install bootstrap4
this generator will:
//= require datatables
add app/assets/javascripts/application.js
*= require datatables
add app/assets/stylesheets/application.css
app/assets/javascripts/
with default init script.app/assets/stylesheets/
lib/template
available styling
Include the JavaScript in your app/assets/javascripts/application.js
:
//= require jquery
//= require datatables
create new file app/assets/javascripts/datatables.js
//Core component
//= require datatables/jquery.dataTables
//Bootstrap4 theme
//= require datatables/dataTables.bootstrap4
//Optional Datatables extensions
//= require datatables/extensions/Responsive/dataTables.responsive
//= require datatables/extensions/Responsive/responsive.bootstrap4
//= require datatables/extensions/Buttons/dataTables.buttons
//= require datatables/extensions/Buttons/buttons.html5
//= require datatables/extensions/Buttons/buttons.print
//= require datatables/extensions/Buttons/buttons.bootstrap4
*** you may refer other extensions in this directory: click me
Include the stylesheet in your app/assets/stylesheets/application.css
:
*= require datatables
or if you using scss
Include the stylesheet in your app/assets/stylesheets/application.scss
:
@import 'datatables';
Create new file app/assets/stylesheets/datatables.scss
** default theme
@import 'datatables/jquery.dataTables';
@import 'datatables/extensions/Responsive/responsive.dataTables';
@import 'datatables/extensions/Buttons/buttons.dataTables';
** if using boostrap4 theme
@import 'datatables/dataTables.bootstrap4';
@import 'datatables/extensions/Responsive/responsive.bootstrap4';
@import 'datatables/extensions/Buttons/buttons.bootstrap4';
*** you may refer other extensions in this directory: click me
Where needed in your JavaScripts, initialize your DataTables:
$(document).ready(function() {
$("#dttb").dataTable();
});
And you will of course, need to have a html table (with a theader and tbody) with the id set to dttb. Here is an example:
<table id="dttb" class="table table-hover">
<thead>
<tr>
<th> Panel No</th>
</tr>
</thead>
<tbody>
<% @panels.each do |panel| %>
<tr>
<td><%= link_to panel.no, panel %></td>
</tr>
<% end %>
</tbody>
</table>
Recommended use this gem
gem 'ajax-datatables-rails'
see docs for details instruction
git commit -am 'My Changes'
)git push origin
)FAQs
Unknown package
We found that jquery-datatables demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.