Reputation: 88197
I currently have defined multple routers for my Backbone app (non-Marionette yet).
authRouter = new AuthRouter()
usersRouter = new UsersRouter()
...
# then to use them
authRouter.navigate "auth/login"
usersRouter.navigate "users/changePassword"
As you can see I am using the variables to navigate. So I must know which router to call. Is it possible to somehow organize code into separate classes but when I want to navigate, just call appRouter.navigate "something"
instead of needing to know which router is it? Marionette recommends not having big routers but doesn't have a recommended way/example of it
Upvotes: 2
Views: 2204
Reputation: 72858
If you look at the annotated source code for Backbone, you'll notice that calling myRouter.navigate
is nothing more than a forwarding method call to Backbone.history.navigate
http://backbonejs.org/docs/backbone.html#section-114
So there's no need to keep track of routers for the navigate method. You can call Backbone.history.navigate directly.
Backbone.history.navigate "auth/login"
Upvotes: 9