没有哈希无法获得骨干路线?

问题描述:

我想有一个浏览器可以捕获和处理可收藏的URL。如果我只是使用的 Backbone.history.start() 的,然后我可以使用哈希的URL,例如 /#帐户

I want to have bookmarkable URLs that the browser can capture and handle. If I just use Backbone.history.start(), then I can use hash URLs, like /#accounts.

但我想没有散列的网址,一拉的 /帐户 的。但我不能得到这个使用工作的 Backbone.history.start({pushState的:真正}) 的(的正如其他人所描述的那样)。我的路线是简单,直接从文档拍摄。

But I want URLs without the hashes, a la /accounts. But I can't get this to work using Backbone.history.start( { pushState: true } ) (as others have described it). My routes are straightforward, and taken directly from the documentation.



    MyRouter = Backbone.Router.extend({
        routes: {
            '/accounts': 'accounts',
        }
    });

我在使用Chrome(也试图与FF),而行为是一个的 /帐户 的请求,径直到服务器。没有被第一骨干截获。有没有人碰到这个?如何得到
 哈希少URL与骨干处理?

I'm using Chrome (also tried with FF), and the behaviour is that an /accounts request goes straight to the server. Not being intercepted by Backbone first. Has anyone run into this? How do I get hash-less URL handling with Backbone?

在此先感谢

您将导航与使用 router.navigate(/账户,真)JS的网址 ,而不是链接或输入自己的网址。要使用链接,必须单击事件绑定到他们,prevent默认的动作,并调用导航到链接HREF。

You would navigate to that url with js using router.navigate( "/accounts", true ), not by links or entering the url yourself. To use links, you must bind a click event to them and prevent the default action and call navigate to the links href.

路由器路由器