I'm not sure how to use namespaces in a modular (RequireJs) Backbone environment.
I thought a little how it looks but I'm absolutely not sure if this is correct.
app.js (getting done by main.js)
define('App', ['underscore', 'backbone', 'Router'], function( _, Backbone, Router){
function initialize(){
var app = {};
app.router = new Router();
Backbone.history.start();
}
return { initialize: initialize }
});
messages.js
define('MessageModel', ['underscore', 'backbone', 'App'], function(_, Backbone, App){
App.Message.Model;
App.Message.Model = Backbone.Model.extend({
});
return App;
});
Is this the right approach or am I completely mistaken (if so, please correct me!)
source
share