I'm trying to append a Loading state
div before the page is redirected.
(https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html)
I have the following link on my page:
<a onclick="showBubble('bubble-placeholder'); return true;" href="http://example.com">Link
</a>
function showBubble(boxClass) {
$('.' + boxClass).append('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
}
When the link is clicked, showBubble appends a div to the other div on the page . And then there is a redirect to http://example.com
It works perfectly fine in all browsers but NOT in webkit browsers on the Ipad.
I found similar problems here Force DOM redraw/refresh on Chrome/Mac and here http://www.eccesignum.org/blog/solving-display-refreshredrawrepaint-issues-in-webkit-browsers
But none of those solutions work for me. I tried:
$('#parentOfElementToBeRedrawn').hide().show(0);
and
$(window).trigger('resize');
and
var n = document.createTextNode(' ');
$('#myElement').append(n);
setTimeout(function(){n.parentNode.removeChild(n)}, 0);
Also, if I click a back button from "example.com" and come back to the previous page, the bubble is there. So, it seems like a webkit browser chooses not to refresh the page before it leaves it.
Also, instead of appending an element to the box, I tried something easier - like changing the text of one of my buttons. It doesn't work either. The page does not refresh after the link is clicked.
Moreover, if I put alert('123') in the onClick property after my showBubble function, the alert shows up but the page is still not refreshed.
But, if I remove the href property from <a>
tag the bubble shows up and everything works. Well, except for that it is not a link anymore :)
I tried to get rid of href and do:
onclick="showBubble('bubble-placeholder'); window.location.replace('www.example.com');"
No success.