I am using jQuery DataTables plugin for a project that uses RequireJS . I loaded the DataTables library and initialization script in the RequireJS app.jsscript and added the corresponding element identifier to the table in the template file. I cannot get DataTables to initialize. It appears that DataTables and RequireJS interact poorly with each other. I do not see console error messages regarding the code below, but it still does not work properly.
Here is my initialization script:
require(["datatables.net"], function() {
$(function() {
$("#example").DataTable({
});
});
});
Here is my RequireJS configuration:
requirejs.config({
config: {
i18n: {
locale: 'en-gb'
}
},
"baseUrl": "js/lib",
"paths": {
"app": "../app",
"jquery": "../lib/jquery-2-0-0.min",
"bootstrap": "../lib/bootstrap.min",
"backbone": "../lib/backbone-min",
"underscore": "../lib/underscore-min",
"text": "../lib/text.min",
"store": "../lib/store.min",
"loader": "../lib/spin.min",
"jquery-insertAtCaret": "../lib/jquery-insertAtCaret",
"splash-clearAndResetModal": "../lib/splash/clearAndResetModal",
"splash-utils": "../lib/splash/utils",
"splash-proofhq": "../lib/splash/proofhq",
"splash-config": "../config",
"datatables.net": "//cdn.datatables.net/1.10.10/js/jquery.dataTables.min",
"datatables-js": "../lib/datatables-js"
},
wrapShim: false,
shim: {
}
});
source
share