-1

I have a simple problem which I am unable to solve. I just started my new .NET MVC5 project in Visual Studio 2015 and I wish to use jquery DataTables. I used NuGet to install jquery.datatables by Allan Jardine. Now that I did that, i see those datatables in references, but not in wwwroot folder. In my wwwroot folder I have bootstrap which works fine. I used the same thing in MVC4, but there are Script folders and Bundles, which don't exist in MVC5.

How can I use my installed DataTables?

References picture

wwwroot picture

My script.js is like this:

alert('a');
$('#prvi').DataTable();

And alert is triggered, but on console view in Chrome, .DataTable() is shown as invalid.

In my _Layout.cshtml I'm referencing to:

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>

I am completely new to MVC5 so I guess this is really trivial issue. Still, I'd really appreciate your help.

4
  • Are DataTables even related to the information you've provided? I thought they were C#/ORM stuff Commented Apr 9, 2016 at 12:23
  • Same question I have already answer it try it, http://stackoverflow.com/questions/36418726/install-datatable-jquery-plugin-in-visual-studio/36419397#36419397 Commented Apr 9, 2016 at 12:30
  • @PrabhatSinha yes, this is the way to use it in MVC4. And there it works. However, in MVC5 i can't seem to get $('#id').DataTable(); to work. I have copied valid DataTable HTML, but JQuery is shown as invalid, meaning that my Datatables.js is not linked correctly Commented Apr 9, 2016 at 12:41
  • @Cubelaster i have already used in my project its working fine. Commented Apr 9, 2016 at 12:43

1 Answer 1

0

While you don't give any further details about your code, perhaps it's a simple typo. the DataTables initializer is actually camelCase. so try:

$('#prvi').dataTable();

Lowercase "d"

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. I already tried that but the result is the same. The console in browser says that it's unrecognised. As if I don't have dataTables.min.js in my solution.
Posting your Razor view code might help. You haven't provided much info here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.