0

I'm trying to emulate the same behavior as that of gmail where the URL changes depending on what link you clicked for example https://mail.google.com/mail/u/0/#inbox.

This link shows how to add a Hash parameter in the URL Rails Routes

Then can use jquery to modify the URL hash to add the hash parameter when the view is loaded

From my testing the following route /route#sent is seen as /route in the server

The part of the puzzle that i'm missing how to route to the corresponding route as the hash parameter is not sent to the server?

Community
  • 1
  • 1
Carlos
  • 938
  • 7
  • 12
  • Server cannot get the url hash as part of _request_ parameters. A dirty approach to do that will involve jQuery. On page load, you can check if url has hash. If it is `/route#sent`, you can make request from JS to something like `/route?query=sent`. When this page loads, url won't have hash, and your JS will compose the hash from the url to `/route#sent`. – kiddorails Apr 16 '16 at 06:59

1 Answers1

0

Part after the hash is mainly for browser. On a loaded page, if the hash changes 1000 times, browser won't request a thing to the server!

Use a JS framework (like Angular/Vue) or jQuery to detect hash changes and load content accordingly!

Babar Al-Amin
  • 3,939
  • 1
  • 16
  • 20