ddewaele / jQueryDataTablesGrunt

Sample project using Grunt / Backbone / jQuery DataTables
0 stars 0 forks source link

DataTables Bootstrap3 library doesn't work after RequireJS Optimizer #1

Open ddewaele opened 10 years ago

ddewaele commented 10 years ago

Running grunt serve:dist

The error

Uncaught TypeError: Cannot read property 'defaults' of undefined 

I added datatables and datatables-bootstrap3 to my bower.json file like this:

{
  "name": "app",
  "version": "0.0.0",
  "dependencies": {
    "jquery": "~1.9.1",
    "datatables": "~1.9.4",
    "datatables-bootstrap3": "git@github:Jowin/Datatables-Bootstrap3.git",
  },
  "devDependencies": {}
}

And then had to modify my RequireJS config to add a shim for datatablesBootstrap3 :

require.config({
    shim: {
        datatablesBootstrap3: {
            deps: ['datatables']
        }        
    },
    paths: {
        datatables: '../bower_components/datatables/media/js/jquery.datatables',
        datatablesBootstrap3: '../bower_components/datatables-bootstrap3/BS3/assets/js/datatables',
    }
});

As far as I understand, this shim config is for "scripts that do not express their dependencies via define()."

Without the shim I got the following runtime error:

Uncaught TypeError: Cannot read property 'defaults' of undefined 
ddewaele commented 10 years ago

Issue can be solved by applying https://github.com/Jowin/Datatables-Bootstrap3/pull/18/files