Datatable doesn't get initialized
I'm currently building a MVC application with C#. I've used a Datatable in my user overview before, but when I want to use it in the detail page, in a partial view, it often doesn't load. Below I've copied the most important part of my DetailsGroup.cshtml file. While coding, I've basically copy/pasted from my working Overview page, but somehow it doesn't work.
- @{
- Layout = "~/Views/Shared/_LayoutWithoutNavBar.cshtml";
- }
-
- <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css" />
- <html>
- ....
- <table id="myGroups">
- ....
- </html>
-
- @section scripts {
- <!-- DataTables -->
- <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- //onderstaand lijntje is om een deftige dataTable te initialiseren
- $('#myGroups').DataTable({
- "searching": false,
- "pageLength": 25
- });
- });
-
- </script>
- }
In my _LayoutWithoutNavBar.cshtml file I have the following bits of code:
-
- <head>
- ...
- @Styles.Render("~/Content/bootstrap-theme.min.css")
- @Styles.Render("~/Content/bootstrap.min.css")
- @Scripts.Render("~/bundles/modernizr")
-
-
- </head>
- <body role="document">
- <div id="mainBody" class="giveMeSomeSpace">
- @Scripts.Render("~/bundles/jquery")
- @Scripts.Render("~/bundles/jqueryui")
- @Scripts.Render("~/bundles/jqueryval")
-
- @RenderSection("scripts", required: false)
-
- @Styles.Render("~/Content/themes/base/css")
- @RenderBody()
-
-
- </div>
- </body>
- </html>
In my main _Layout.cshtml file, which is also used in the Details page, I use the same scripts, described above. I don't know if a partial view can use those though, so I kinda copy/pasted to be sure.
I almost forgot. When I run the app, I don't get an error, the table just gets sloppily loaded, no functionality or css. If I open F12 on Chrome, I see a red *Uncaught TypeError: undefined is not a function* If I click on that error, it sends me to the < head > tag of my main Details page
What possible causes could there be?