Reputation: 2642
I have errors loading jquery-menu-aim
and bootstrap
with Require.js in backbone project.
Here are what I had defined in main.js of :
requirejs.config({
enforceDefine: true,
paths: {
//declare path jquery, backbone, underscore,and other library here....
"jquery-menu-aim" : "libs/jquery/jquery.menu-aim",
"bootstrap" : "libs/jquery/bootstrap.min"
},
shim: {
"jquery-menu-aim" : {
deps: ["jquery"] ,
exports: "Jquerymenuaim"
},
"bootstrap" : {
deps: ["jquery"] ,
exports: "Bootstrap"
}
}
});
Errors : Uncaught Error: No define call for jquery-menu-aim http://requirejs.org/docs/errors.html#nodefine require.js:8 Uncaught Error: No define call for bootstrap http://requirejs.org/docs/errors.html#nodefine
When I defined it in my view. I think maybe I was wrong in defining library in Shim config, but I can not found it in google.
Any help would be appreciated. Thanks.
Upvotes: 2
Views: 2227
Reputation: 151401
Your shim for Bootstrap is definitely wrong because Bootstrap does not define a symbol named Bootstrap
. Here's what I use:
bootstrap: {
deps: ["jquery"],
exports: "jQuery.fn.popover"
},
The jQuery.fn.popover
method is something that Bootstrap defines. If it is absent after RequireJS has loaded Bootstrap, that's a sure sign that Bootstrap has not loaded.
Your shim for jquery.menu-aim is similarly wrong. Looking at the code, I see it is a jQuery plugin. You should change your shim to check for a function it adds to jQuery. jQuery.fn.menuAim
looks like a good candidate.
Upvotes: 4