backbone.js attaching multiple Routers to the same route

September 16, 2011 3 Comments by Richard

Recently I had need to attach multiple backbone.js Router objects to the same route; the purpose was to create a page which could have multiple sections that were unaware of each other, since the path gave them all the information they needed. This allowed a much looser form of coupling and gave us a bit more of a MVP feel rather than a traditional MVC.

However, after a lot of discussion we ended up scrapping this plan for a slightly different one.  I had already written a patch to make backbone.js routers support multiple route handlers, though, and I didn’t think it made sense to just throw it out, so I’ll provide it here.  Keep in mind that this may not work with future versions of backbone.js!

So, without further ado, here it is:

[gist id=1223417 bump=3]


  1. Anonymous
    10 years ago

    What was the reason not to use multiple routers?

  2. taxilian
    10 years ago

    We were originally having unrelated parts of the program manage different areas of the page, but ended up revising that to have a router that handled multiple areas, so we didn’t need this any more.

One Trackback

  1. […] it works just fine; the only time you’d have a problem is if they have conflicting routes. There is a workaround that makes it work that way as well, but it’s a bit of a […]

Post a Comment

Your email is never published or shared. Required fields are marked *