Multiple routers with backbone.js -
Multiple routers with backbone.js -
can utilize multiple routers in backbone.js
, don't interfere each other route-wise, without issues? or there should concerned about?
code sample:
myapp.routers.main = backbone.router.extend({ routes : { "": "index" }, index : function() { console.log("routed main router");} }); myapp.routers.another = backbone.router.extend({ routes : { "notmain": "index" }, index : function() { console.log("routed router");} }); mainrouter = new vaikava.routers.main; notmainrouter = new vaikava.routers.another; backbone.history.start();
yes, works fine; time you'd have problem if have conflicting routes. there workaround makes work way well, it's bit of hack.
as long avoid having multiple routers trying handle same route should fine.
backbone.js router
Comments
Post a Comment