I am trying to add DataTables plugin to one of my pages and no matter where I put the js and css links I get errors. I tried head.cshtml in DefaultClean and the root body and head as well and I still causes javascript errors. I even tried in the body of the cshtml view I am creating. Examples. Am I putting the right references?
CSHTML:
$(document).ready(function() {
$('#example').DataTable();
} );
Head.cshtml:
Html.AppendScriptParts(ResourceLocation.Footer, "~/scripts/DataTables/datatables.min.js", themeName);
Html.AppendCssFileParts(ResourceLocation.Head, "~/scripts/DataTables/datatables.min.css", themeName);
or SampleView.cshtml:
@*<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>*@ <----Already included in head.cshtml right?
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css" />
Errors:
jquery.min.js:2 Uncaught TypeError: $(...).DataTable is not a function
at HTMLDocument.<anonymous> (localhost/:2343)
at l (jquery.min.js:2)
at c (jquery.min.js:2)