Skip to content Skip to sidebar Skip to footer

Datatables+requirejs: Cannot Read Property 'defaults' Of Undefined

I have downloaded the full package of DataTables with all its module, since it can't be accessed through the CDN URL: https://www.datatables.net/download/ (all options selected) I'

Solution 1:

An acceptable answer would be just to download the individual modules (instead of the single file option) and use the following script, it seems to cause less problems than including all at once:

http://jsfiddle.net/42ucpwee/2/

requirejs.config({
    appDir: ".",
    baseUrl: "js",
    paths: {
        'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min',
        'bootstrap': '//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min',
        'datatables' : 'jquery.dataTables.min',
        'datatables-bootstrap' : 'dataTables.bootstrap',
    },
    shim : {
        'jquery' : {
            exports : 'jquery'
        },
        'bootstrap' : {
            deps : [ 'jquery' ],
            exports : 'Bootstrap'
        },
        'datatables' : [ 'jquery' ],
        'datatables-bootstrap' : [ 'datatables' ],
    }
});
require([
    'jquery',
    'datatables-bootstrap'
], function ($) {
    $('#example').DataTable();
});

Post a Comment for "Datatables+requirejs: Cannot Read Property 'defaults' Of Undefined"