I have a single page website that pulls in content via ajax. when the page is first loaded it runs an init() function that checks the url and decides what content to be added to the DOM based on that url with a switch statement using ajax. The problem is that mainly on my iphone does the init function not get called about 60% of the time. I am out of ideas on to what might be happening here, if someone could shine some light on the situation i would be more than thankful. The only thing i can think of is the loading order is getting intangled and so the init function calls nothing or freezes some how. The page does not freeze itself by the way just the content that is supposed to be loaded is not showing. My entire script is wrapped in an object of portfolio. i am just going to post the functions i feel might be causing the problem.if you need more of the script let me know. Here is some of my javascript:
init: function(){
var location = document.URL.substr(document.URL.lastIndexOf('/') + 1), //Grabs the last segement of the url and assigns it to a value
page;
portfolio.footer.empty();
switch(location){
case 'contact-page':
$('#main-nav ul li.contact-page').addClass('active');
page = 'contact';
break;
case 'about-page':
$('#main-nav ul li.about-page').addClass('active');
page = 'about';
break;
case 'portfolio-page':
$('#main-nav ul li.portfolio-page').addClass('active');
page = 'portfolio';
break;
default:
$('#main-nav ul li.portfolio-page').addClass('active');
page = 'portfolio';
break;
}
portfolio.loadProjects(page);
portfolio.loadFooter();
},
loadProjects: function(page){
portfolio.footer.empty();
//$('#portfolio').css('height', '100%');
portfolio.ajaxCall('portfolio-wrapper', "partials/"+page+".html");
if(page === 'portfolio'){
portfolio.getProjects();
}
portfolio.loadFooter();
},
ajaxCall: function(context, page){
var loading = function(){
$('.'+context+'').html(
'<div id="loader">'+
'<img id="loader-img" alt="" src="img/loading-dog.gif" width="100" height="100" align="center" />'+
'<p>Loading..</p>'+
'</div>'
);
};
$('.'+context+'').load(page, loading(), function(result) {
if(portfolio.w<=1000){
portfolio.project.fadeOut('fast').empty().append(result).stop().css({opacity: '0', display: 'block'}).animate({opacity: '1'}, 1000);
}else{
portfolio.project.fadeOut('fast').empty().append(result).stop().css({marginLeft: '-1200px', opacity: '0', display: 'block'}).animate({marginLeft: '0', opacity: '1'}, 1000);
}
});
},