Muhammad Usman
Muhammad Usman

Reputation: 1362

Uncaught TypeError: undefined is not a function for datatables

I am working in ASP .NET MVC4. When jquery is loaded then I got an error Undefined is not a function by using jquery. enter image description here

In HTML version its working correctly but when it loaded through compiler it is not working correctly.

Upvotes: 3

Views: 11110

Answers (5)

Api
Api

Reputation: 1831

Well if you are using AMD pattern, you would need to keep your module name to "datatables" so that you don't get "Uncaught TypeError: jQuery(...).DataTable is not a function"

Below link was helpful. https://datatables.net/forums/discussion/21178/amd-definition-without-explicit-module-name

Upvotes: 0

bajuwa
bajuwa

Reputation: 330

I think the problem is constructor DataTable(), It is supposed to be capitalized.
Instead of $('#dt_inbox').dataTable() use $('#dt_inbox').DataTable()

Upvotes: 1

kregus
kregus

Reputation: 1108

I was struggling with the same problem for hours.. My issue was resolved when I changed the $ to jQuery in my code.

Upvotes: 0

Muhammad Usman
Muhammad Usman

Reputation: 1362

Sorry I am answering my own question I got error for this question it is just rearranging file sequence in file loading Thanks to all who give me time to solve my problem

Upvotes: 3

Stepan Riha
Stepan Riha

Reputation: 1724

You problably forgot to add the plugin to your bundle. The following questions goes into more details:

Usage of the ASP.NET MVC4 jquery/javascript bundles

Upvotes: 0

Related Questions