I divided my app in several apps.
main.js
app.js
app1/
|- routing
|- controller
|- app
app2/
|- routing
|- controller
|- app
1) When I try to use the routers in app1
, they work.
2) When I try to use the routers in app2
, they don't work.
3) If I comment the line 'js/app1/routing',
in main.js
the routers in app2
work.
Why do I get this behaviour?
Is there some example of app using multiple routing and requirejs on github?
thanks.
Here's my code:
** main.js **
define([
'js/app',
'js/app1/routing', // the routers in this app work
'js/app2/routing' // the routers in this app do not work but
// if I comment the previous line (js/app1/routing',)
// they works
],
function (App)
{
"use strict";
App.initialize();
});
** app.js **
define([],
function ()
{
"use strict";
var app = new Backbone.Marionette.Application();
return app;
});
** app1/rotuing **
define(['backbone','app1/controller'], function(Backbone, controller)
{
"use strict";
var Router = Backbone.Marionette.AppRouter.extend({
appRoutes: {
'*defaults': 'index1'
}
});
return new Router({
controller: controller
});
});
** app2/routing.js **
define(['backbone','app2/controller'], function(Backbone, controller)
{
"use strict";
var Router = Backbone.Marionette.AppRouter.extend({
appRoutes: {
'app2': 'index2'
}
});
return new Router({
controller: controller
});
});