0

I am facing issue while calling the function using ExecuteOrDelayUntilScriptLoaded() I am writing like:

<script language="javascript" type="text/javascript">
 ExecuteOrDelayUntilScriptLoaded(PopulateDropDown, "sp.js");
</script>

Now my function PopulateDropDown() doesn't get executed.

2

There is a slight difference on how ExecuteOrDelayUntilScriptLoaded works depending on what page it is being executed on.

Sometimes SP.js is available and other times it is not. When it's not availble, the call to ExecuteOrDelayUntilScriptLoaded will fail as SP.js is not loaded.

View my answer to a similar question here for more on this.

1

ExecuteOrDelayUntilScriptLoaded Method

You can try this:

jQuery(document).ready(function() {
 ExecuteOrDelayUntilScriptLoaded(myfunction, "sp.js");
});

myfunction = function(){
 /*Do something here.*/
};

Or try following the answer found here:

ExecuteOrDelayUntilScriptLoaded(function () { alertThis("Hello World") }, "core.js");

function alertThis(value)
{
  alert(value);
} 
1

In SharePoint 2013 prefer SP.SOD.executeFunc(key, functionName, fn) Method instead of SP.SOD.executeOrDelayUntilScriptLoaded(func, depScriptFileName) Method to ensure that sp.js library is loaded before the specified callback function runs.

Solution

Replace:

ExecuteOrDelayUntilScriptLoaded(PopulateDropDown, "sp.js");

with

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', PopulateDropDown);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.