PROBLEM FIXED FOR NOW.
I fixed it by deleting my javascript section for a sticky header that scrolls with the page. i really don't know why my javascript is crappy when that code is in application.html.erb
My datatables will work when my application.html.erb looks like this:
<!DOCTYPE html>
<html>
<head>
<title>Dummyapp1</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application", "contractens" %>
<%= csrf_meta_tags %>
<div>
</head>
<body>
==rest of script==
and it does not work when my application.html.erb looks like this:
<!DOCTYPE html>
<html>
<head>
<title>Dummyapp1</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application", "contractens" %>
<%= csrf_meta_tags %>
<div>
</div>
<!-- If you have jQuery directly, then skip next line -->
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// If you have jQuery directly, then skip next line
google.load("jquery", "1");
function sticky_relocate() {
var window_top = $(window).scrollTop();
var div_top = $('#sticky-anchor').offset().top;
if (window_top > div_top)
$('#sticky').addClass('stick')
else
$('#sticky').removeClass('stick');
}
// If you have jQuery directly, use the following line, instead
// $(function() {
// If you have jQuery via Google AJAX Libraries
google.setOnLoadCallback(function() {
$(window).scroll(sticky_relocate);
sticky_relocate();
});
</script>
</head>
<body>
I follow this Railscasts Tutorial for datatables in rails. i had this in my other app. there it works fine. I did the same thing as the other app but it is showing me text instead of the actual table.
Here´s my view for the table:
<h1>Listing contracten</h1>
<table id="contractens" class="display">
<thead>
<tr>
<th>Naam</th>
<th>Omschrijving</th>
<th>Datumingang</th>
<th>Contractduur</th>
<th>Opzegtermijn</th>
<th>Betalingstermijn</th>
</tr>
</thead>
<tbody>
<%= @contractens.each do |contracten| %>
<tr>
<td><%= contracten.naam %></td>
<td><%= contracten.omschrijving %></td>
<td><%= contracten.datumingang %></td>
<td><%= contracten.contractduur %></td>
<td><%= contracten.opzegtermijn %></td>
<td><%= contracten.betalingstermijn %></td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to "Nieuw", new_contracten_path %>
and my javascript files are filled in correct.
here´s a screenshot of the issue:

Hope you can help me :)
EDIT: it should look like this with no css:

and it should look like this with css:

This is my contractens.js.coffee :
jQuery ->
$('#contractens').dataTable
sPaginationType: "full_numbers"
bJQueryUI: true
This is my application.js:
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require_tree .
And this is my application.css:
/*
*= require_self
*= require dataTables/jquery.dataTables
*= require_tree .
*/
EDIT 2:
when i have a javascript function to hide a div when clicking a checkbox. when i have
jQuery ->
$('#contractens').dataTable
in my contractens.js.coffee it does work, but when i have:
jQuery ->
$('#contractens').dataTable
sPaginationType: "full_numbers"
bJQueryUI: true
it does not work either. so something is blocking the jquery i guess.
$('#contractens').dataTable()?