Pushstate 在backbone.js 中无法正常工作
如果我将 Backbone 与 Pushstate 一起使用,我应该如何格式化我的链接?
目前我正在这样做:
<a href="task/create">create task</a>
如果我使用上述格式,它实际上会向服务器发送一个 GET
请求,该服务器提供标准页面,并且骨干网正确识别它应该转到 task/create
,它确实这样做了,并显示了视图。
但为什么它首先要发送 GET
请求呢? (即使我已将pushstate设置为true?)
编辑:我正在使用最新版本的Chrome(截至2011年8月),所以我认为我的浏览器不是问题。
If I am using Backbone with pushstate, how should I format my links?
Currently I am doing this:
<a href="task/create">create task</a>
If I use the above format, it actually sends a GET
request to the server, which serves a standard page and backbone correctly identifies that it should go to task/create
, which it does, and shows the view.
But why is it sending a GET
request in the first place? (even though I have set pushstate to true?)
edit: I am using the latest version of Chrome (as of August 2011), so my browser is not a problem, I think.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,从这里得到了答案。 https://github.com/documentcloud/backbone/issues/456
单击链接不应该是推送状态友好的。人们可以尝试通过 jquery 实时绑定它并使用自定义函数来创建该效果。
ok got it answered from here. https://github.com/documentcloud/backbone/issues/456
clicking links are not suppose to be pushstate friendly. one may try to live bind it via jquery and use custom function to create that effect.
如果其他读者想了解有关路由的更多信息,请参阅第 32-46 页中的一整章专门解释路由:http://samples.leanpub.com/marionette-gentle-introduction-sample.pdf(完全披露:我是本书作者)
In case any other readers would like more information on routing, there's a whole chapter dedicated to explaining routing available in pages 32-46 here: http://samples.leanpub.com/marionette-gentle-introduction-sample.pdf (full disclosure: I'm the book author)