Installed the gem but cannot see any change on table: datatables in Rails 3.2.1:

Installed the gem but cannot see any change on table: datatables in Rails 3.2.1:

arrow0927arrow0927 Posts: 5Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Hi I was following this video tutorial here:
http://railscasts.com/episodes/340-datatables

I got the gems to install on my app. Here are all the files I modified to get it to work:
gemfile:
[code]
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-datatables-rails'
end
[/code]
added an id to the table, added the thead and tbody links. Then in the application.js file I added this line
[code]
//= require dataTables/jquery.dataTables
[/code]
in application.css I added this line:
[code]
*= require dataTables/jquery.dataTables
[/code]
In the javascript/coffeescript file I added this line
[code]
jQuery -> $('#rlistings').dataTable()
[/code]

However, I am not seeing the datatable change much. The table has only visually been modified a bit, but there is no search box, no pagination, no sorting capabilities. In short Javascript is not working....

Im confused, as the above video tutorial is quite recent and Ive followed all the steps. Yet, its not working. Ive also looked at this

[code]
https://github.com/rweng/jquery-datatables-rails
[/code]

and followed these steps.

What could I be doing wrong? How can i get this to work?
Where should I start?
Please help me

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sounds like you probably have a script error. What does firebug say?

    Allan
  • arrow0927arrow0927 Posts: 5Questions: 0Answers: 0
    I figured it out. In my table some of the columns had checkboxes as a form. This was causing the problem. Once I took the form items out, the table worked. The question then is, is it possible to use datatables when I have form elements in my table. Cause it seems like right now I cannot, it somehow interferes with the script
  • arrow0927arrow0927 Posts: 5Questions: 0Answers: 0
    Looks like there is another subtlety in datatables:

    I have a column in my datatables implementation which is a link to edit a "listing" like so:
    [code]
    <% @listings.each do |listing| %>


    <%=listing.id%>
    <%=link_to listing.name, edit_listing_path(listing) %>
    ..............
    [/code]

    Now when this link is clicked it leads to the "show" view of this listing instead of the "edit" view. To try and see if its the link or rails routing, I tried to take the same link and paste it outside the datatable on the same page like so:

    [code]
    <%=link_to @listings.first.name, edit_listing_path(@listings.first.id) %>
    [/code]


    this seems to work fine. So that tells me that somehow, all "post"/"put" requests are changed to "get" requests inside the datatable.

    Could someone pleae help me to figure out, whether it is possible to embed check boxes and edit links within the datatable?

    Thanks a lot
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It is - you just do it like you would with a normal HTML table. If it is Javascript that is driving the links, you might need to take into account page: http://datatables.net/faqs#events

    Allan
  • arrow0927arrow0927 Posts: 5Questions: 0Answers: 0
    Thank you. I will check this out.
  • arrow0927arrow0927 Posts: 5Questions: 0Answers: 0
    This is still not working for me. I looked at the event example but it didnt help. An actual example with checkboxes or any form items in the datatable would be super helpful. Doesanyone know of any links or anything.

    Thanks
This discussion has been closed.