【发布时间】:2016-08-08 03:32:34
【问题描述】:
我正在尝试模拟与 gmail 相同的行为,其中 URL 会根据您单击的链接而变化,例如 https://mail.google.com/mail/u/0/#inbox。
此链接显示如何add a Hash parameter in the URL Rails Routes
然后可以使用jquery to modify the URL hash to add the hash parameter when the view is loaded
根据我的测试,以下路由 /route#sent 在服务器中被视为 /route
我缺少的部分难题如何route to the corresponding route as the hash parameter is not sent to the server?
【问题讨论】:
-
服务器无法将 url 哈希作为 request 参数的一部分。一种肮脏的方法将涉及 jQuery。在页面加载时,您可以检查 url 是否有哈希。如果是
/route#sent,你可以从JS向/route?query=sent之类的东西发出请求。当这个页面加载时,url 不会有 hash,你的 JS 会从 url 到/route#sent组合 hash。
标签: jquery ruby-on-rails ruby