Basically the problem is I have a side navigation which loads its content into the #main section of the page. No issues there.
snip:: (this is the function that loads the page from the side nav)
$(document).on('click', "a.page_load", function (e) {
e.preventDefault();
var cur = $(this).parent().hasClass('active');
if(cur){
return false;
} else {
$.ajax({
type: "GET",
url: $(this).attr("href"),
cache: true
})
.error(function(response,error) {
.....
})
.done(function(response){
.....
});
return false;
}
});
So that is the first request made.
Then history binds to the a click.
$(document).ready(function() {
$(function() {
var History = window.History;
if (!History.enabled) {
return false;
}
History.Adapter.bind(window,'statechange',function() {
var State = History.getState();
$('#pageCore').load(State.url);
$('a').click(function(evt) {
evt.preventDefault();
History.pushState(null, $(this).text(), $(this).attr('href'));
});
});
});
I tried disabling the global
$('a').click(function(evt) then nothing worked, added
History.pushState(null, $(this).text(), $(this).attr('href')); directly into the a.page_load snip above but the
$('#pageCore').load(State.url); still makes the second request.
removed the
$('#pageCore').load(State.url); which is making the second request for the content, the site worked but the url never changed. Just loaded the pages as normal but everything just said /home.
My main ajax function does everything , just want to forward and back functionality that history has.
Any help would be great.
Thanks in advance.
Dave