1

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?

2
  • i am looking to do the same thing, which version of gems and rails did you used ? Commented Jun 11, 2013 at 10:50
  • 1
    I am using rails 3.2.x and the latest bootstrap and datatable gems as of June 2013. Main thing is remove all references to the datatable css Commented Jun 16, 2013 at 6:34

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.