I have a site that displays (or that's the plan at least) content dynamically, but it has some problems. When I open the site for the first time and click on a link, it loads the content dynamically. When I go back and press a link again, it reloads the whole site. I feel like I'm missing something important, what can it be?
Ajax:
$(document).ready(function () {
var container = $('#content');
$('a').click(function (e) {
e.preventDefault();
var url = $(this).attr('href');
//$('#content').hide('fast');
history.pushState({path: url}, null, url);
container.load(url);
return false;
});
$(window).bind('popstate', function (event) {
var state = event.originalEvent.state;
if (state) {
container.load(state.path);
}
});
history.replaceState({path: window.location.href}, '');
});