Last active
November 11, 2021 13:32
-
-
Save zplume/661debc3dd87f9dad649 to your computer and use it in GitHub Desktop.
Example code to ensure that a function is executed on all page loads, including MDS page loads (where partial page loading is used for navigation rather than full postbacks).
This file contains hidden or 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
// define a global function to execute | |
function $_global_onMDSPageLoad() { | |
// code to execute on page load goes here | |
} | |
ExecuteOrDelayUntilScriptLoaded(function () { | |
if (typeof asyncDeltaManager != "undefined") | |
asyncDeltaManager.add_pageLoaded($_global_onMDSPageLoad); // execute on MDS page load | |
else | |
$_global_onMDSPageLoad(); // execute on non-MDS page load | |
}, "sp.js"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment