Hi guys need some help here, I'm still learning jquery..... sorry for the trouble
I've setup a div of #content with a #content-wrap as a wrapper, I use the below code to load pages dynamically into #content that is on the same directory, I've dynamically loaded the pages from index.php with no problems, but when I click on a link on a dynamically loaded page, it does not add hashes and doesn't work at all.
E.G. -I've clicked on a link call portfolio from index.php -then portfolio is loaded in div #content with url of localhost/website/index.php#portfolio -the portfolio page has links linking to other pages in the same directory -after clicking any of them, for example a link to a page call webdesign, none of them has hashes and does't work just redirects to localhost/website/webdesign
Is there a way to fix this? making it load dynamically for contents loaded by ajax? i know there's on() and delegate(), but i don't know how to use them
please help, urgent
Thanks
Kenwin
- $(document).ready(function(){
var loadingImage = $('<img src="./preloader.gif"/>'); - //initial
$('body').fadeIn('slow'); - //start of coding
$('#nav ul li a, .footleft a, #logo a, .webdesign a, .graphicdesign a, .printdesign a, .photography a, .personalprojects a, #portfoliowrapper a').each(function(){
$(this).attr('href', '#' + $(this).attr('href'));
});
$(window).bind('hashchange',function(e){
var page = e.fragment;
$('#content').hide().load(page + '.php' + '#content-wrap').fadeIn('slow');
});
1