user802232
user802232

Reputation: 2611

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.

Upvotes: 0

Views: 305

Answers (2)

ninja123
ninja123

Reputation: 1099

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.

Upvotes: 0

Elf Sternberg
Elf Sternberg

Reputation: 16361

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.

Upvotes: 2

Related Questions