3

I've been trying various ways to plug in jQuery DataTables to my mvc app. After reading http://datatables.net/blog/Microsoft_CDN, I decided that using Microsoft's CDN might be the easiest approach to just get a DataTable up and running.

I copied and pasted the exact code found in the blogs example into Index.vbhtml, but I get "$("#example").dataTable is not a function". I also tried using the DataTable debugger but it does not find any DataTables on my page.

Because I'm an ASP.net noob and I haven't found any similar problems anywhere, I feel that the problem is something simple that I'm just overlooking. So I apologize in advance if this is a ridiculous question, but any help is much appreciated.

3
  • Can you get it working in MVC 3? Find a complete MVC 3 sample. What does $("#example").Text() produce? Commented Jul 6, 2012 at 17:07
  • Make sure you are adding jQuery's javascript file to the page before the Datatables javascript file. Commented Jul 6, 2012 at 17:34
  • I double checked and the JQuery js file is in fact added before the Datatables. I'll work on trying it MVC 3 but I thought I would let you know that $("#example").Text() produces the name of the columns followed by the all of the data that is inside the table. Commented Jul 6, 2012 at 17:54

1 Answer 1

3

I suspect a conflict with different versions of jquery. The version on the CDN and the version of jquery bundled in your MVC site could be conflicting.

Look in your /Views/Shared/_Layout.vbhtml (or _Layout.cshtml for C#) for this line:

@Scripts.Render("~/bundles/jquery")

Comment it out and try again, if it works then it was a conflict.

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

1 Comment

That means that datatables does not work with MVC4 default jquery version ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.