James Freeman
Member
Hi,
I am writing some code for the front end of my site. I'm forced to use AJAX as our page loading method. We use anchors as hooks to detect what page the user was on (not sure if that's needed).
I'm having some problems with a tags after the DOM is loaded. So if you click onto another page which is loaded from AJAX it doesn't take the _initPages(); route.
Now, I know what you are going to say, just run that function every time I detect a hash change. I don't want to do that.
What I'm asking is there any jQuery function that looks at the DOM on click instead of at the time of the function is ran. Errr, confusing.
Thanks,
Code:
I am writing some code for the front end of my site. I'm forced to use AJAX as our page loading method. We use anchors as hooks to detect what page the user was on (not sure if that's needed).
I'm having some problems with a tags after the DOM is loaded. So if you click onto another page which is loaded from AJAX it doesn't take the _initPages(); route.
Now, I know what you are going to say, just run that function every time I detect a hash change. I don't want to do that.
What I'm asking is there any jQuery function that looks at the DOM on click instead of at the time of the function is ran. Errr, confusing.
Thanks,
Code:
Code:
__construct: function()
{
this._initPages();
$(window).bind('hashchange', function()
{
mySite._detectHash();
if( mySite._hash )
{
mySite._loadPage(mySite._hash);
}
});
$(window).trigger("hashchange");
this._init();
},
_initPages: function()
{
$( 'a:not(.noAjax)' ).on( 'click', function( )
{
window.location = '/#!/' + $( this ).attr('href');
return false;
} );
}