1

Can anyone tell me how I can use:

ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");

in my Client Web Part pages (App Parts)?

In my standard pages it loads fine but when I try use this function in an app part page I keep getting an undefined error:

enter image description here

What resource/script do I need to load on the page to get this function to work?

2

I had this same issue and this worked for me

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

Make sure you add a reference to init.js script

 <script type="text/javascript" src="/_layouts/15/init.js"></script>

I have not tried the following, but it should work after loading init.js

SP.SOD.ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");
| improve this answer | |
0

I would have though that it would be in either the SP.js or the SP.Core.js file (although I can't confirm for definite). But have you tried:

SP.SOD.ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");

| improve this answer | |
  • Yes, I tried that immediately after posting the question. Exact same error. If I inspect the SP object, it exists but SP.SOD is undefined. Really frustrating as it's hard to find documentation around this in the context of App Parts. – Ray Hogan Apr 19 '16 at 11:45

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.