I am stuck on a bit of an issue. I have employed AJAX navigation (with url fallback for bots) on my site and, while the navigation works great on click of navigation options on the site itself, the browser’s back/forward buttons I’m struggling to get working. Here is the script:
function newfeat2(page) {
var formData = "page=" + page;
$.ajax({
url : "/ajax/nav_page.php",
type: "POST",
data : formData,
success: function(data, textStatus, jqXHR) {
$('#top_features').fadeOut('fast', function() {
$(this).empty(); $(this).append(data).fadeIn('slow');
});
},
error: function (jqXHR, textStatus, errorThrown) {}
});
scrollToAnchor('featbar',46);
adtracker();
//browser history
var doctitle = 'Featured Archive - Trailer Addict';
document.title = 'Featured Archive - Trailer Addict';
var urlPath = '/featured/'+ page;
//window.history.pushState({"html":response.html,"pageTitle":doctitle},"", urlPath);
window.history.pushState('feature-id:'+ page, doctitle, urlPath);
}
I believe I need to bring the onpopstate into play and I think my objectState in pushState is fouled up.
Seeking advice/solution to get the backbone/forward button working in browser.
I figured that wasn’t right. When I tried creating an object with variables I kept getting javascript errors. Are variables allowed in the objectState?
When it comes to the back button, it would be cool for it to navigate in AJAX and do all the effects and such, but at this point I’d accept if the back button would just go directly to the URL I supplied in urlPath.