0

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?

4

1 回答 1

1

我真的不会使用内部 Backbone 机制,尤其是当您可以移动代码以实现 Backbone 标准时。

我宁愿建议修改您的所有网址以接受这两个新值:

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

此外,您想使用手工机制提取和存储这些值,这正是 Router 的含义之一,如果您不小心,最终可能会重新发明轮子

于 2012-08-16T08:08:48.717 回答