TableTools w/ RequireJS does not find DataTables

TableTools w/ RequireJS does not find DataTables

NitropyeNitropye Posts: 2Questions: 0Answers: 0
edited March 2013 in TableTools
I'm using DataTables w/ RequireJS and all works well w/ vanilla DataTables. Once I try and load in TableTools I get an alert dialog saying DataTables 1.9+ is required but I'm running 1.9.4.

After some digging around it appears that $.fn.DataTable isn't found at all.

This error is popped in console

[code]
TypeError: 'undefined' is not an object (evaluating '$.fn.DataTable.TableTools = TableTools').
[/code]

An abbreviated version of my code looks like this:

[code]
define(['lib/jquery.dataTables',
'lib/jquery.dataTables.tableTools'], function() {

$('#tableelement').dataTable({
"sDom": 'T<"clear">lfrtip'
});
}
[/code]

I tried with both TableTools versions 2.1.5.dev and 2.1.4.

Replies

  • NitropyeNitropye Posts: 2Questions: 0Answers: 0
    Fixed my own issue.

    For anyone interested what was happening is TableTools was being loaded before DataTables. The RequreJS config option "shim" lets you get around this.

    [code]
    require.config({
    shim: {
    'lib/jquery.tableTools': {
    deps: ['lib/jquery.dataTables']
    }
    }
    });
    [/code]

    Hope this helps someone else in the future!

    Peace.
  • sbmitchesbmitche Posts: 1Questions: 0Answers: 0
    This helped me thanks!
This discussion has been closed.