I've been reading a lot on this, and even bought a book specifically on setting up marionette apps with require.js, and followed this little how-to on github which seemed pretty straightforward... However for some reason I can't seem to get something as simple as starting an empty Marionette project to work!
My project is structured like so:
- Root Directory
- models
- views
- libs
- babysitter.js
- backbone.js
- jquery.js
- marionette.js
- require.js
- text.js
- tpl.js
- underscore.js
- wreqr.js
- collections
- templates
- index.html
- main.js
Here's my index.html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script data-main="main" src="libs/require.js" type="text/javascript"></script>
</body>
</html>
And my main.js:
require.config({
paths:{
jquery:"libs/jquery",
underscore: "libs/underscore",
backbone: "libs/backbone",
text: "libs/text",
tpl: "libs/tpl",
marionette: 'libs/marionette',
'backbone.wreqr' : 'libs/wreqr',
'backbone.babysitter' : 'libs/babysitter'
},
shim:{
underscore:{
exports: "_"
},
backbone:{
deps: ['underscore','jquery'],
exports:'Backbone'
}
}
});
require(['marionette'],function(Marionette){
var Application = new Marionette.Application();
Application.on("initialize:after", function(){
alert("Application has started!");
});
Application.start();
});
I downloaded the AMD / RequireJS version of Marionette.js from their site
Upon opening up index.html in a browser, I see an error in the console "Reference Error: Backbone is not defined" (on marionette.js line 20)
What am I doing wrong?