Routes chaining in Backbone.js
Using backbone.js, is it possible to chain Url routes?
if I have something like that:
routes: {
"home*splat":"showHomeView",
"home/view_:param"开发者_如何学运维:"handleViewChange"
}
I'd like to be able to say something like .../#home/view_gallery and both handlers to fire in the order in which they were declared.
This however, fires only the first handler.
The router runs through the keys
of routes
in order, and for the first one that matches, calls the Router[value].apply(params)
, and then stops.
So, no, URL routes will not chain. One route per URL hash change event.
This makes for a perfect candidate for a backbone routing plugin that can extend Backbone's already existing Routing mechanism. I am in the process of building one and possibly can open source it when done.
精彩评论