0

I've followed along with the following tutorials to get DataTables setup in my Rails app, but I am seeing no change. Here's what I followed:

https://github.com/rweng/jquery-datatables-rails

http://railscasts.com/episodes/340-datatables

I am not getting an error. I'm just seeing no change. And I restarted my server.

Application.js

//= require dataTables/jquery.dataTables

Application.css

*= require dataTables/jquery.dataTables

View:

<table id="products">
    <thead>
      <tr>
        <th>Name</th>
        <th>Price</th>
      </tr>
    </thead>

    <tbody>
        <tr>
          <td>Something</td>
          <td>Something</td>
        </tr>
        <tr>
          <td>Something</td>
          <td>Something</td>
        </tr>
        <tr>
          <td>Something</td>
          <td>Something</td>
        </tr>
    </tbody>
</table>

Products.js.coffee

jQuery ->
  $('#products').dataTable

I just want to be able to sort columns. Why is this not working?

1 Answer 1

1

Try converting Products.js.coffee back to regular javascript and seeing if the results are the same. If so, the problem is either with the javascript itself or the compilation of the coffeescript (make sure the coffee-rails gem is in the Gemfile). Also check out the RailsCast Coffeescript Episode.

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

2 Comments

What do you mean by the statement: 'make sure the gem is there'? Is that a gem for coffeescript or is there another gem for datatables to make it work with coffeescript?
Yes, make sure coffee-rails gem is in the Gemfile. Also, at the end of the RailsCast/AsciiCast mentioned there are additional debugging tips. I updated the answer to make it more clear.

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.