How to build url hierarchy for project composed with decoupled Backbone.js
apps?
I like the way how Django do subj. It allows to define 'local' url inside
apps, and then include them in project-level root url config and define
prefixes for them.
Like - local urls are: that/<id>, this/<slug>/ and global prefix for
entire app - verygoodapp/.
In Backbone.js this can be done through root parameter for History.start()
function.
But in this case I will need to do
History.start({root:
arbitraryUrlPrefixForThatAppPassedAsArgFromAboveLocalSpace})
in every applciation.
Is it ok? How js gurus do that?
upd
I wrote that and realized that probably I need just write:
function(urlRoot) {
var MyRouter = Backbone.Router.extend({
routes: {
urlRoot + 'content/:slug': 'openArticle'
},
...
});
}
And do History.start() just once in global project space. Am I right?
No comments:
Post a Comment