Link to home
Start Free TrialLog in
Avatar of chuang4630
chuang4630

asked on

Question on RequireJS and Jquery datatables

I received the following error:


Uncaught TypeError: Cannot read property 'oApi' of undefined

jquery datatables: DataTables-1.10.3
RequiresJS: RequireJS 2.1.18

main.js:
require.config({
    shim: {
        jquery: {
            export: '$'
        },
        jqueryui: { deps: ["jquery"] },
        'jquery.validate': { deps: ["jquery"] },
        'datatables': { deps: ["jquery"] },
        angular: {
            exports: 'angular',
            deps: ["jquery"]
        },
        angularApp: {
            exports: 'angularApp',
            deps: ['angular']
        },

        global: { deps: ["jquery"] }
    },
    paths: {
        jquery: ['//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0',
          // fallback to local jQuery
          //'libs/jquery'
          'jquery-2.1.0.min'
        ],
        'datatables': 'DataTables-1.10.3/jquery.dataTables',
        bootstrap: 'bootstrap',
        less: 'less.min',
        'jquery.validate': 'jquery.validate',
        domReady: 'libs/domReady',
        'angularApp': '/bundles/app?',
    }
});

// Require Global dependencies
require(['jquery', 'jquery.validate', 'jqueryui', 'global',
    'bootstrap',
    'less',
    'angularApp'
], function ($, jqvalidate, jqueryui, global) {

    // Since we're loading angular asynchronously, we must handle the bootstrapping process
    angular.module('orbit').init();

    // Load scripts for IE
    if ($('html').hasClass('lt-ie9') || $('html').hasClass('ie9')) {
        require(['/Scripts/jquery.placeholder.js'], function (ieScript) {
            // fix placeholders for IE9 and below
            $('input, textarea').placeholder();
        });

    }

});

_layout.cshtml:

        <script data-main="@Url.Content("~/Scripts/main")" src="@Url.Content("~/Scripts/libs/require.js")"></script>

I have spent over a day on this issue but couldn't configured it out.
Need help on the problem.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial