1
I’m trying to apply requireJS to my application, because I’m having some problems.
require-config.js
var require = {
paths: {
"jquery": "/admin/admin-v2/bower_components/jquery/dist/jquery.min",
"bootstrap": "/admin/admin-v2/bower_components/bootstrap/dist/js/bootstrap.min",
"metismenu": "/admin/admin-v2/bower_components/metisMenu/dist/metisMenu.min",
"morris": "/admin/admin-v2/bower_components/morrisjs/morris.min",
"raphael": "/admin/admin-v2/bower_components/raphael/raphael-min",
"morrisdata": "/admin/admin-v2/controllers/js/morris-data",
"datatables": "/admin/admin-v2/bower_components/datatables/media/js/jquery.dataTables.min",
"datatablesbootstrap": "/admin/admin-v2/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min",
"global": "/admin/admin-v2/js/sb-admin-2"
},
shim: {
'jquery': {
deps: [],
exports: '$'
},
'bootstrap': {
deps: ['jquery']
},
'metismenu': {
deps: ['jquery']
},
'raphael': {
deps: ['jquery'],
exports: 'Raphael'
},
'morris': {
deps: ['jquery', 'raphael'],
exports: 'Morris'
},
'morrisdata': {
deps: ['jquery', 'morris']
},
'datatables': {
deps: ['jquery']
},
'fatatablesbootstrap': {
deps: ['jquery', 'datatables', 'bootstrap']
},
'global': {
deps: ['jquery', 'metismenu']
}
}
};
This is my app.js:
require(['jquery', 'bootstrap', 'datatables', 'datatablesbootstrap', 'global'], function () {
$(function () {
//my code goes here
});
});
I’m getting this error in Chrome: Uncaught Error: Bootstrap’s Javascript requires jQuery console
I defined jquery in bootstrap dependencies so I don’t understand what the problem is
If I take all the functions and leave only jquery in the call of require it is recognized, but if I add any other dependency it ceases to be recognized.
Test pass the
$
in the callback... like this..., 'global'], function ($) {
– Sergio
You managed to solve the problem?
– Bruno Wego