Ad

DataTable Is Not A Function, What's Wrong?

- 1 answer

I'm using datatable on a laravel project. But table is not rendering. It is showing the error:

Uncaught TypeError: $(...).DataTable is not a function
    at HTMLDocument.<anonymous> (dashboard:147)
    at l (datatables.min.js:14)
    at c (datatables.min.js:14)

I've included jQuery, js and css as following order

  • jQuery
  • datatable js
  • datatable css

what else might cause the problem?

Ad

Answer

make sure to load the jquery.js before the preferred dataTable.js file.

<script type="text/javascript" src="~/Scripts/jquery.js"></script>
<script type="text/javascript" src="~/Scripts/data-table/jquery.dataTables.js"></script>

 <script>$(document).ready(function () {
    $.noConflict();
    var table = $('# your selector').DataTable();
});</script>
Ad
source: stackoverflow.com
Ad