Reputation: 4228
I'm writing a Marionette application using require.js and AMD.
I'm taking Jsoverson's version of the Addy Osmany's ToDoMVC as code example. I'm adapting it to my needs, even if there is not much documentation about this version.
Whenever I load my page I get this 404 errors in the browser Console:
GET http://127.0.0.1:8000/static/js/backbone.wreqr.js 404 (NOT FOUND) require.js:1836
Uncaught Error: Script error
http://requirejs.org/docs/errors.html#scripterror require.js:160
GET http://127.0.0.1:8000/static/js/backbone.eventbinder.js 404 (NOT FOUND) require.js:1836
GET http://127.0.0.1:8000/static/js/backbone.babysitter.js 404 (NOT FOUND) require.js:1836
Uncaught Error: Script error
http://requirejs.org/docs/errors.html#scripterror
Now, I have seen that backbone.wreqr "is an infrastructure for decupling Backbone and Backbone.Marionette application modules and components" written by the author of Marionette. Also backbone.eventbinder and backbone.babysitter are projects written by the author.
1) I don't understand why should I include these files considering the code example I'm following did not use any of them and it works just fine.
2) These files are required in the wrong path anyway. My application is organized in this way:
Staticfiles/
|__js/
| app.js
| main.js
| models/
| ectr.
|__lib/
backbone/
Backbone.js
Marionette.js (AMD version)
Underscore.js
ectr.
So why it is looking for those files under thejs/
folder?
3)Is it a Require.js problem or it is just an error in my js application?
Upvotes: 0
Views: 2398
Reputation: 4660
If you want to stick with the dependent version of Marionette (for example, you are using JamJS like me), you can include them in your main.js configuration of Require. For example, here is mine:
require.config({
paths: {
marionette: 'lib/Backbone.Marionette/lib/core/amd/backbone.marionette',
'backbone.babysitter': 'lib/Backbone.BabySitter/lib/amd/backbone.babysitter',
'backbone.wreqr': 'lib/Backbone.Wreqr/lib/amd/backbone.wreqr'
}
});
This goes before the main require() call of your app.
Upvotes: 2
Reputation: 2841
Those files are needed for Marionette to work properly, but the author decouple them from Marionette so they can be used in other projects too.
I suggest you to download the bundled version of Marionette which has all the needed dependency files included:
http://marionettejs.com/#download
Upvotes: 2
Reputation: 9845
RequireJS assumes that all of your scripts are located in the same base directory as your main.js
file.
If you want to specify a different base directory, use the baseUrl
configuration option:
<!-- In main.js -->
require.config({
baseUrl: "/another/path"
});
Upvotes: 1