Skip to content

Instantly share code, notes, and snippets.

@zplume
Last active November 11, 2021 13:32
Show Gist options
  • Save zplume/661debc3dd87f9dad649 to your computer and use it in GitHub Desktop.
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).
// 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