I ran into the same problem. I think the reason this error occurs is because DT_bootstrap.js not an AMD module, but depends on side effects. In this case, jquery.dataTables.js .
When RequireJS optimizer combines all the modules you reference into one large JS file, raw DT_bootstrap.js is somewhere in the middle, at some place after jquery.dataTables.js . The problem is that DT_bootstrap.js is evaluated immediately after loading your js file. He wants $.fn.dataTable be determined when he encounters a string:
$.extend( true, $.fn.dataTable.defaults, {
Since jquery.dataTables.js is an AMD module, it has been compiled but not yet evaluated. Only in later code, where it is required as a dependency, will it be evaluated, and only after that will it define $.fn.dataTable .
I worked on this by wrapping "DT_bootstrap.js" in the AMD module definition, as is done here: https://github.com/amdjs/backbone/blob/master/backbone.js#L8-L24
For example:
(function(root, factory) { // Set up DT_bootstrap appropriately for the environment. if (typeof define === 'function' && define.amd) { // AMD define(['jquery', 'datatables', 'bootstrap'], function($) { factory($); }); } else { // Browser globals factory(root.jQuery); } }(this, function($) { // <--- original DT_bootstrap.js goes here }));
He solved the problem for me.
Peter Long
source share