Reputation: 17368
I am looking for a way to navigate between pages and respond to events when the anchor changes with jQuery. In order to illustrate my question, let me demonstrate with an example:
http://thesite.com/
to http://thesite.com/#/
, without any page refresh.<a href="#/author/bio">My Bio</a>
.$.ajax()
method to load the requested page, without a page refresh.http://thesite.com/#/
, without a page refresh.I am good when it comes to loading the page content. However, here is what I don't know:
http://thesite.com/#/
, if it is not supplied when the page loads?Sorry for the crash list of questions. If my scenario wasn't clear enough, then here is a great site that already does it: http://grooveshark.com/.
Thank you for your time! I will reward generously for thorough answers/comments.
Upvotes: 0
Views: 2317
Reputation: 775
First load jquery.
on ready change all urls something like
$('a').forEach(function(obj){
obj.href=obj.href+"#";
});
// on click load
$('a').click(function(a){
ajaxLoad(a);
//push to window.history
});
Upvotes: -1