Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Routers and Controllers with require.js

I came across this in the wiki:

It is recommended that you divide your controller objects into smaller pieces of related functionality and have multiple routers / controllers, instead of just one giant router and controller.

I didn't understand how to apply this. Are there any examples or tutorials?

Right now, I'm playing with Marionette and using require.js. How would I go about implementing multiple routers and controllers?

like image 894
chapani Avatar asked Dec 10 '12 18:12

chapani


1 Answers

I ended up with this in my "main.js":

MyApp.start();

new BlogRouter({
    controller: new BlogController()
});

new NewsRouter({
    controller: new NewsController()
});

Backbone.history.start();

I'm not sure if it's the right approach. But it's working. Hope it will help some newbies like me.

like image 185
chapani Avatar answered Nov 14 '22 12:11

chapani