Search code examples
jqueryasp.net-mvc-4jqxwidgets

Jqwidgets are not working in MVC4


I'm trying to make use of jqwidgets in my project which is built under asp.net mvc4 concept, the below code gives me an error "Uncaught TypeError: Cannot read property ‘dataAdapter’ of undefined", please bare in mind that below code is just an example demonstrating that something is wrong with my implementation of the components into my project.

@model KhoonehYab.Models.User
@{
    ViewBag.Title = "Create";
}
<script src="~/Scripts/jqwidgets/jqxcore.js"></script>
<script src="~/Scripts/jqwidgets/jqxdata.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var data = new $.jqx.dataAdapter([]);
    });
</script>

The jquery version being used is 1.9 (added in bundle & loaded in _layout) & jqwidgets v2.8.1, also tried with other older versions of both and got the same error, it also happens for any other jqwidget libraries such as simplest one, jqxButton. I've been stuck over this for 2 days already and I don't know what I'm doing wrong. Any troubleshooting from you guys is appreciated in advance.

Thanks


Solution

  • it is not just to include the scripts. The scripts in MVC4 should be in: @section scripts { }.