"Uncaught TypeError: $(...).DataTable is not a function" - script order seems fine? help :/
"Uncaught TypeError: $(...).DataTable is not a function" - script order seems fine? help :/
Hi!
So I am trying to implement data tables in my MVC application, and I am stuck getting this error in my index view on:
I have ofcourse googled and the two things I have seen causing this was .DataTable having a small D, or because the scripts were in the wrong order. To be sure I am trying with the least interference possible I made a basic MVC project, and in the layout page I added the three references to in the head-section (had to edit the .js cause of formatting here. But its from the manual.
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.css">
<...charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<...charset="utf8" src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.js"></script>
And in my index view I have:
$(document).ready(function () { $('#myDataTable').DataTable(); });and the table, sorry for the horrible formatting but had to escape the html.But its taken straight from the manual.
<table id="myDataTable" class="display"><br/> <thead><br/> <tr><br/> <th>Column 1</th><br/> <th>Column 2</th><br/> </tr><br/> </thead><br/> <tbody><br/> <tr><br/> <td>Row 1 Data 1</td><br/> <td>Row 1 Data 2</td><br/> </tr><br/> <tr><br/> <td>Row 2 Data 1</td><br/> <td>Row 2 Data 2</td><br/> </tr><br/> </tbody><br/></table>
Copied straight out of the manual, so to say. But still the table shown is as plain and useless as ever, and when using F12 debug tools in chrome I get the initial error. Is there anything else obvious I am overlooking?
Hoping to get some quick help/input, thanks :)
Cheers,
Morten
Answers
I tried to use the test case here:
http://live.datatables.net/diluluse/1/edit?html,css,js,output
it seems to work fine on this link, but not when Im debudding/running my webservice.
The only difference from the above test case and my index view is that the reference to the scripts are on the _Layout page.
We'd need to be able to access your web service to offer any help, or have access to a test case that reproduces the issue. As you say, your example appears to work okay, so I don't know what would be different between that any your web service.
Allan