Drongo_III Posted September 26, 2012 Share Posted September 26, 2012 Hi Guys I wonder if someone can help. Essentially it's a jquery script that makes a scrolling div track the page. So when you scroll down the page the div follows you. That works fine. The issue is that if a user clicks back, or forward on the iPad the jquery seems to simply fail and the scroll event stops working. I tried to strip the page down to test this with just a straight alert as follows: $(document).ready(function(){ alert(1); }); This code fires fine on page load and alerts 1, but if I then navigate away, and then click back, the alert doesnt fire. I am guessing this is a caching issue but I was wondering if anyone had encountered this problem and what the best solution is? Any advice welcome as iPad design is all very new to me. Drongo Quote Link to comment https://forums.phpfreaks.com/topic/268827-jquery-and-ipad-issue/ Share on other sites More sharing options...
Christian F. Posted September 26, 2012 Share Posted September 26, 2012 I think I'd rather use position: fixed; in CSS instead, that'll work even if JS is completely disabled. Quote Link to comment https://forums.phpfreaks.com/topic/268827-jquery-and-ipad-issue/#findComment-1381134 Share on other sites More sharing options...
Drongo_III Posted September 26, 2012 Author Share Posted September 26, 2012 Thanks christian. That's a possible solution but it's more complicated than that...for instance it can't be allowed to overlap the footer or header. Hence the jquery. Any ideas on how to get around the forward/Back issue? Quote Link to comment https://forums.phpfreaks.com/topic/268827-jquery-and-ipad-issue/#findComment-1381138 Share on other sites More sharing options...
Christian F. Posted September 26, 2012 Share Posted September 26, 2012 In that case I'd add a JS to check on scroll, which checks of the page is at top/bottom (or # pixels away from it), and then suitably adjusts the position of the div. If the browser clears out the JS events when going to a new page, and doesn't load them anew when going back in the history, there's little you can do about it. The only recourse you have is to check an event handler which it does fire, and hopefully is directly related to what you want. Quote Link to comment https://forums.phpfreaks.com/topic/268827-jquery-and-ipad-issue/#findComment-1381149 Share on other sites More sharing options...
Drongo_III Posted September 26, 2012 Author Share Posted September 26, 2012 Sorry I realise this is all a bit abstract. I had hoped it would be a known issue with a known solution. The problem is even if I did re-detect the element's position, and reset it, the actual scroll event simply doesnt work when you click back. This is a toughy :/ as even the simple jquery alert in my example didn't work. Do you think I'd have more luck with straight javascript? Would an onload function get preserved perhaps? I realise the ready event is similar. hmmm Quote Link to comment https://forums.phpfreaks.com/topic/268827-jquery-and-ipad-issue/#findComment-1381156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.