1

My environement is SP2013

I am unable to run below code under Content Editor WebPart loaded below EditForm.aspx page for one of my test list. Please assist the spot of my error. Yes, both of my js files are in Style Library of my site. I am not getting alert message. seems SP.JS is not loaded or not found.

These scripts are loaded in the content editor window

<script src="/sites/documentit/Style%20Library/jquery-1.10.1.min.js" type="text/javascript"> </script> 
<script src="/_layouts/SP.js" type="text/javascript"> </script> 

And this script is failing to execute

 $(document).ready(function(){
     SP.SOD.executeOrDelayUntilScriptLoaded(function(){
        alert("jquery");     
     } , "SP.js");
 });
J. Chomel
  • 8,193
  • 15
  • 41
  • 69
Chintan.Desai
  • 31
  • 1
  • 2
  • 8
  • You are trying to load SP.js with an SP function? Any chance you could post a bit more code? Is the SP script loaded inside the master template, or by your Conted Editor WebPart? Could you show the exact error message inside the debugger window (F12)? – Icepickle Oct 23 '15 at 11:24
  • Actually, now I have editted your post, I would say that you don't need the second call to SP.SOD.executeOrDelayUntilScriptLoaded as JQuery will anyhow be doing this for you. The JQuery ready function will only fire when all scripts are loaded and the DOM is ready to be manipulated, so imho, you don't need your extra waiting block – Icepickle Oct 23 '15 at 11:34
  • Hi Icepickle, I am not getting any error when I click View Item (DispForm.aspx) for item in list. I was expecting Alert() to display in View Item click. I have shown you whole code. I dont know how to use debbugger window for error. – Chintan.Desai Oct 23 '15 at 11:37
  • Well, would this page help you to get a bit further? http://yakovenkomax.com/sharepoint-2013-page-load-events/ It basically explains the same, and that you should choose between document.ready of JQuery and executeOrDelayUntilScriptLoaded func... – Icepickle Oct 23 '15 at 11:40
  • Thanks for the link. I removed the SP.SOD.executeOrDelayUntilScriptLoaded() code and working only with $(document)...code. However, I am still not getting the alert message. – Chintan.Desai Oct 23 '15 at 12:06
  • Can you update your start post with the changed code? (Edit it?) – Icepickle Oct 23 '15 at 12:07

0 Answers0