Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:58:41+00:00 2026-06-06T11:58:41+00:00

PROBLEM FIXED FOR NOW. I fixed it by deleting my javascript section for a

  • 0

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:

issue

Hope you can help me 🙂

EDIT: it should look like this with no css:

enter image description here

and it should look like this with css:

enter image description here

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:58:43+00:00Added an answer on June 6, 2026 at 11:58 am

    Change

    <%= @contractens.each do |contracten| %>
    

    for

    <% @contractens.each do |contracten| %>
    

    The <%= %> tag set is used when you want output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Regarding my previous problem that is now fixed, I got another problem with the
Update: I've fixed up my referencing below, and my problem is now more specific.
Edit : The bug that caused this problem has been fixed. The @version tag
I tried searching and didn't find anything that fixed my problem. I have a
I had a problem (which is now fixed) but I've no idea why... I
Thanks everybody for the reply! Now I fixed the problem by R 2.12.1 and
[Update 2011-09-21 11:19] I've fixed one problem that was causing a problem and that
Now, thanks to community, one problem was fixed ( Delete all elements of a
THIS PROBLEM IS NOW FIXED see updated css below. I currently have: $(form#FanDetail).serialize(), function(){
Problem fixed, see below What I'm doing is this: Generate random number -> store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.