3

Possible Duplicate:
How does github change URL without reloading a page?


I don't know how to describe but how does this cool slide effect on github file explorer work?
Not the graphical part but the javascript/ajax logic behind. It seems like the page isn't reloading and the next directory just slides in. I thought that with javascript you only can change the hash, not the whole path of the url.
So, how is it possible to change the url from somedomain.com/foo to somedomain.com/foo/bar without reloading the whole page, just loading the new content via ajax or websockets. I definitly don't know how to do this, or with which trick this works on github.

Community
  • 1
  • 1
Felix Scheinost
  • 423
  • 1
  • 4
  • 14

1 Answers1

3

You can use javascript libraries for this kind of thing. A good one is History.js. It uses push state when it can and falls back to hash bang urls when not. I've used it in a couple of projects and find it really good especially if you use js templates as well. Such as Dust.js

Here is a link to the Historyjs github page history js.

As far as the ajax goes. I used a type identifier on my url. So when a user navigates to /home, there is no page reload and instead an ajax call is dispatched to /homepage.json From which a json response is retrieved and then rendered into the dom or the js template.

Maleck13
  • 1,709
  • 15
  • 17