Unable to get a new installation to work
Unable to get a new installation to work
measterbrook
Posts: 14Questions: 5Answers: 0
in DataTables
I am using ASP.Net MVC 5 and I'm not able to get DataTables to work. I have a regular HTML table and am using version 1.11.3 of DataTables. I am using jQuery 3.6.0.
At the top of the page I have:
<script src="~/jQuery-3.6.0/jQuery-3.6.0"></script>
<link rel="stylesheet" type="text/css" href="/DataTables/datatables.css">
<script type="text/javascript" charset="utf8" src="/DataTables-1.11.3/datatables.js"></script>
And I have the script file at the bottom of the page:
<script src="~/Views/IndexFooter/IndexFooter.js"></script>
The script file is:
$(document).ready( function () {
$('#indexTable').DataTable();
} );
When I open the HTML page, it doesn't look or function any differently.
Answers
The code snippets look good. Its hard to say what the problem is without seeing it.
Do you get errors in the browser's console?
Is the id of the
table
indexTable
? Its case sensitive.Have you used the browser's debugger to make sure your last code snippet is executed?
If this doesn't help 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
I have been using DataTables with regular HTML for several years with no problems. This is my first try using it with ASP.Net.
And yes the table id is "indexTable"
The problem was that the layout file for the page had a second call for jQuery:
<script src="~/lib/jquery/dist/jquery.min.js"></script>
I commented it out and now it works.