Question

I am getting a maddening error trying to load an html page(with angular/javascript,etc) from a content editor inside a sharepoint 2013 aspx.page. I have several sites where I do the exact same thing(using the same template) and it works without issue.

This site page doesn't want to work using the exact same code. I am at my wits end as to why this is happening and throwing an error. Basically I get a blank page at the end because it keeps throwing errors about sp.js, then SP.Publishing and the SP.Pub being undefined and then it doesn't do anything after that, except give me a blank page.

I already am using

<script type="text/javascript"> $(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(function () { }, "sp.js"); }); </script>

I have also put the Microsoft.Ajax script on the page that defined Type but to no avail, still get the same error.

on the index html page, so this should be waiting for it to load, but it isn't.

I checked and double checked my code between the pages that are working without issue and this one and the markup is exactly the same, and the code is the same as well.

Does anyone know why this would be happening??

UPDATE: The crazy thing about this is, it works in edit mode when I apply the link but not once I go to the page directly...this is very irritating

Was it helpful?

Solution 2

OK, I finally figured out how to get this to work after at least 15 hours spent looking up and trying literally everything I could find. I still am not exactly sure why it works, but it works.

Basically I create a content editor but instead of linking it to an HTML page in the site assets folder, I rename the HTML page to an ASPX page and it works, and that is really it.

All that time and effort and simply renaming the HTML page to an ASPX page is all that it took to get it to work.

OTHER TIPS

I never work with this document-ready construct. I always use

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

at the top of the script described e. g. in this post

That the edit page behaves differnt could be a hint to the order of script references. Especially with Angular the order is important. If the above executeFunc does not help you may post how you've lined up the references for the other script-files / how your script header looks like.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top