Created
February 13, 2018 20:20
-
-
Save ablanathtanalba/de649114725ff57a548812e9cb071810 to your computer and use it in GitHub Desktop.
Merlin Guides Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SOLUTIONS TO DETECT IF A PAGE IS LOADING | |
After Ajax calls are made it runs the cb function | |
*/ | |
//in the rare case that jquery is not already included, | |
//this appends it to the head | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"; | |
head.appendChild(script); | |
//checks elements in page to see if document has any divs labeled 'loading' | |
//runs callback func, to be determined later | |
if(document.querySelector('.loading') || document.querySelector('#loading') { | |
$(document).ajaxComplete(function(cb){ | |
cb(); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment