When building a SPA or another type of ‘front-end heavy’ app, there’s a matter of representing and switching between pages and subpages. You can parse the url along with anything that’s after the “#” (used so that the browser will not refresh the page after changing the url), but that’s just plain ol’ boring. Here’s how you do it with sammy:
You need to make sure that this code is run after the DOM is ready – so preferably, at the end of your document.
jQuery is required.
This may not seem like much, but if you look at it closely it is very handy. The best comparison I can think of is that this serves the same purpose as the routing mechanism in asp.net. It allows you to decouple your views from your routes and (what’s more important) switch them automatically. I love it.