gucki
gucki

Reputation: 4762

backbone.js and scoped urls

Currently I keep the current locale and account id only in global variables. But now I need to embed them in the url's of my backbone application, so the users can copy/ paste the url.

Currently:

/#users
/#documents
/#images
...

Desired:

/#de/32/users
/#de/232/documents
/#de/4452/images
...

I wonder what's the best way to extract and store the current locale and account id from the url before any router processes it. This way I should be able to leave all routers as they are, am I?

Do I have to "hack" this into the routers (something like in https://github.com/documentcloud/backbone/pull/299) or is there any better way?

Upvotes: 0

Views: 214

Answers (1)

fguillen
fguillen

Reputation: 38772

I really wouldn't play with internal Backbone mechanism, especially when you can move your code to accomplish the Backbone standards.

I rather recommend to modify all your urls to accept the two new values:

:locale/:account_id/users
:locale/:account_id/documents
:locale/:account_id/images
...

Also, you want to extract and store these values with a handmade mechanism and this is exactly one of the meanings of Router, if you are not careful you can ended up reinventing the wheel.

Upvotes: 1

Related Questions