I am using jQuery to load page content when a link is clicked,
$(document).on('click', 'nav a', function (e) {
e.preventDefault();
var url = $(this).attr("href");
window.history.pushState('', '', url);
url += " #main_wrapper > *";
$('#main_wrapper').load(url);
});
The problem is when i click on the Back button, URL changes and nothing happens.. How can i load the content again when the back button is clicked?
And how can i stop/cancel existing Load when a new link is clicked?
Thanks.
EDIT:
This is how i implemented this, You can easily modify this to your needs.
window.onpopstate = function(event) {
$('aside nav a').removeClass('active');
$('a[href="' + document.location + '"]').addClass('active')
$('#main_wrapper').load(document.location +" #main_wrapper > *");
};