[SOLVED] DataTables with requirejs problem

[SOLVED] DataTables with requirejs problem

moriciomoricio Posts: 5Questions: 0Answers: 0
edited April 2014 in DataTables 1.10
I have a problem with new version of DataTable.
All is ok with 1.9.4.

I get "TypeError: $(...).dataTable is not a function" :((

Here's how I use it:

main.js
[code]require.config({
baseUrl: "/medias/js/",
paths: {
"jquery": "//ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.0.min",
// "datatable": "//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min",
"datatable": "//datatables.net/download/build/nightly/jquery.dataTables.js?_=99823af74ba032ba950452c707888b11",
"css": "libs/css.min",
},
shim: {
"datatable": {
deps: ["jquery", "css!/medias/css/dataTable.css"]
}
},
map: {
"*": {
"css": "libs/css"
}
}
});[/code]

And the calling inside php script:
[code]
requirejs(["datatable"], function() {
var oTable= $('#Histo').dataTable({
"bInfo": false,
"bAutoWidth": false,
"bFilter": false,
"aaData": [ <?php echo $aaData; ?>],
"aoColumns": [<?php echo $aoColumns; ?>],
});
});
[/code]

Replies

  • allanallan Posts: 57,300Questions: 1Answers: 9,127 Site admin
    DataTables identifies itself as a named module, so you need to use the same name - in this case `datatables` . http://live.datatables.net/deluluk/1/edit .

    This behaviour matches how jQuery registers itself as a named module and I felt it was that safest way given that the extensions can also be loaded this way.

    Allan
  • moriciomoricio Posts: 5Questions: 0Answers: 0
    Thank you very much.
    Everything works perfectly like that.

    I wish to congratulate you, your job is just perfect.
This discussion has been closed.