开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜