Skip to content

Uncaught TypeError: $(...).DataTable is not a function #214

@stilney

Description

@stilney

I get the following error in the console when I try to use DataTables

Uncaught TypeError: $(...).DataTable is not a function

I ran the following code to setup dataTables
gem 'jquery-datatables-rails', '~> 3.3.0'
bundle install
$ rails generate jquery:datatables:install
$ rails generate jquery:datatables:install bootstrap3
$ rails generate jquery:datatables:install responsive

I restarted the rails server, and added this code.

//my_javascript.js
$(document).ready(function(){
  $('#test-table').DataTable({
        responsive: true
    });
});
//my_erb_file.erb
 <table class="display" id="test-table">
          <thead>
          <tr>
            <th>Name</th>
            <th>Job</th>
            <th>Start date</th>
            <th>Location</th>
            <th>Desk Location</th>
            <th>Manager</th>
            <th>Status</th>
          </tr>
          </thead>
          <tbody>
              <tr class="options">
                <td>test</td>
                <td>test</td>
                <td>test</td>
                <td>test</td>
                <td>test</td>
                <td>test</td>
                <td>test</td> 
              </tr>
          </tbody>
        </table>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions