Michael Moulsdale
Michael Moulsdale

Reputation: 1488

jquery-datatables-rails bootstrap styling

In rails I am using bootstrap and dataTables via the jquery-datatables-rails gem. However, I only seem to get half the bootstrap styling.

gem 'jquery-datatables-rails', git: 'git://github.com/rweng/jquery-datatables-rails.git'

application.js

    //= require jquery
    //= require jquery_ujs
    //= require jquery.ui.core
    //= require jquery.ui.datepicker
    //= require twitter/bootstrap
    //= require dataTables/jquery.dataTables
    //= require dataTables/jquery.dataTables.bootstrap
    //= require dataTables/extras/TableTools
    //= require chosen-jquery
    //= require best_in_place
    //= require cocoon
    //= require_tree .

    $.extend( $.fn.dataTableExt.oStdClasses, {
      "sWrapper": "dataTables_wrapper form-inline"
    } );

application.css

 *= require_self
 *= require jquery.ui.core
 *= require jquery.ui.datepicker
 *= require dataTables/jquery.dataTables.bootstrap
 *= require dataTables/extras/TableTools
 *= require dataTables/extras/TableTools_JUI
 *= require chosen
 *= require_tree .
 */

specific coffee script

jQuery ->
  $('#customers').dataTable
    sDom: "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>"
    sPaginationType: "bootstrap"
    bjQueryUI: true

erb

<table id="customers" class="display" cellpadding="0" cellspacing="0" border="0" class="table table-bordered table-striped">  
  <thead>
    <tr>
      <th>etc.

However the styling is the one shown below and not that shown on the dataTable site http://www.datatables.net/media/blog/bootstrap/

Note the header is wrong and the stripes are purple not grey

enter image description here

Any thoughts on what else I need to do?

Upvotes: 1

Views: 5000

Answers (1)

Michael Moulsdale
Michael Moulsdale

Reputation: 1488

This all boiled down to my lack of understanding of the assets pipeline. Once I got my head around that more things worked well.

It seemed that I had played around with the precompile and compress options in development and so the public/assets directory had css files in that were overiding anything else I used.

Once I deleted the contents of that directory and configured my capistrano deployment to do a precompile on production everything worked well.

The asset pipeline is certainly excellent, but needs some care.

Upvotes: 1

Related Questions