Data table conflict with require-jquery.js

The current application, some of them used require-jquery.js. Now I have completed the jQuery data table. It works fine when removing "require-jquery.js". But when I turn on require-jquery.js, I get the error message below:

Error: inconsistent anonymous define () method: function ($) {

See structure:

  • jquery.min.js
  • jquery.js required
  • jquery.dataTables.js

And this:

tickerdashboardtable = $('#tickerdashboardtable').dataTable( {} );

I do not know how to use require-jquery.js. How to solve this problem.

+5
source share
1 answer
<script data-main="scripts/main.js" src="scripts/jquery.js"></script>

Create main.js that contains something similar to:

require(["jquery", "jquery.alpha", "jquery.beta"], function($) {
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
    $(function() {
        $('body').alpha().beta();
    });
});

You must call any scripts that use "define ()" from the require-jquery API.

http://requirejs.org/docs/jquery.html

0
source

All Articles