I am using iOS 8.2
I have a div with class .loading-screen
and a link which, when clicked, prompts a controller to do something which takes a few seconds at least (a file is generated), and then the page refreshes. After the link .generate-button
is clicked, I want to display a popup to the user which basically says "Your file is generating - please wait."
Here is my code, trimmed to show the basics:
jQuery
jQuery(document).ready(function() {
jQuery(".generate-button").click(function (e) {
alert('generating - click!');
jQuery(".loading-screen#generating").addClass('show');
});
});
HTML
<a href="http://example.com/link/generate/id/101/" class="button generate-button">Generate file</a>
....
<div class="loading-screen" style="display: none" id="generating">
<p>Your file is generating!</p>
</div>
CSS
.loading-screen {
z-index: 5000;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.loading-screen.show {
display: block !important;
}
On Chrome and Firefox this is working fine. I am having some issues with Safari, particularly on iOS.
I have read that other posts stating the click event on Safari is not working - jQuery click events not working in iOS - my confusion is that, with my code, the alert is showing when the link is clicked, but the popup is not showing.
I have tried using jQuery(".generate-button").hover(...)
instead and this does generate the popup, but then (obviously) does not navigate to the link.
Is it to do with Safari realising that the page is being navigated away from, so not rendering any further changes on the page? This is my only theory at present.
In Safari on a Mac the behaviour is that the page is navigated away from (to the URL given in the link), which is different to Chrome/Firefox, but that is not such an issue for me at the moment.
Help or ideas appreciated. Thanks.