Using draw without JS files

Using draw without JS files

ValhallaSkiesValhallaSkies Posts: 9Questions: 2Answers: 0
edited March 2021 in Free community support

Is it possible to use draw without using the datatables.min.js? I have my own custom JS for the datatables but draw doesn't seem to work using a range filter. I get "Uncaught TypeError: table.draw is not a function".

var table = $('#example').dataTable({
                    'pageLength': 25,
                    'columnDefs': [
                     {
                            "targets": [ 5 ],
                            "visible": false
                        },
                  ]
                });

                $('#slider-range').change( function() {
                    table.draw();
                });

Thank you.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    See this FAQ. You have

    var table = $('#example').dataTable({
    

    But you need to use DataTable with a capital D, like this:

    var table = $('#example').DataTable({
    

    Kevin

  • ValhallaSkiesValhallaSkies Posts: 9Questions: 2Answers: 0

    Thank you that worked. Now I need to figure out how to fix the filters in the head. Here is a before and after changing it to the Capital version.

    Before

    After

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    You can always go back to using the old version var table = $('#example').dataTable({ then change your click event to get the API, for example:

                    $('#slider-range').change( function() {
                        var table = $('#example').DataTable();
                        table.draw();
                    });
    

    Otherwise please provide a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • ValhallaSkiesValhallaSkies Posts: 9Questions: 2Answers: 0

    Amazing, Thank you. This will allow so much more for my building.

This discussion has been closed.