TableTools w/ RequireJS does not find DataTables
TableTools w/ RequireJS does not find DataTables
Nitropye
Posts: 2Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
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.