$(document).ready() always works when its a complete page load/refresh but not when there are controls enabled with ajax doing async callback or Minimial download strategy(sharepoint 2013) is enabled for the site that reloads only the changes in the page.Know more about Minimal Download Strategy by reading this.
Also, Its not always necessary that the page is loaded following MDS but sometime may reload. So both cases need to be handled when writing scripts(jquery/javascript)
Below is the code that i could make use of that could fulfill this scenario.
$(function () {
ExecuteOrDelayUntilScriptLoaded(function () {
if (typeof asyncDeltaManager != "undefined")
asyncDeltaManager.add_endRequest(doSomething); //after MDS loads the changes
else doSomething();
}, "start.js");
});
function doSomething()
{
//write something
}
No comments:
Post a Comment