0

I have a strange situation. I using the code below in a Java Script file and referencing it from CEWP. For some reason, I can't do Page or Site Action Edit anymore, it does not do nothing. However, if i delete the file or delete the reference from cewp then the page becomes editable. (btw, it's happening regardless of jquery location)

<script src="_layouts/jquery/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="_layouts/jquery/jquery-ui-1.10.4/jquery-ui.min.js" type="text/javascript"></script>
<script src="_layouts/jquery/jquery.SPServices-2014.01.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="_layouts/jquery/jquery-ui-themes-1.10.4/themes/smoothness/jquery-ui.css" />

I added following code but Edit Page still throws an error and does not let edit the page.

$(document).ready(function(){   
    ExecuteOrDelayUntilScriptLoaded(PostLoad,'SP.js');
});

Here is the error from developer console

SCRIPT5007: Unable to get property 'PageState' of undefined or null reference 
sp.ribbon.js, line 2 character 79472
  • where is the "code below"? – Tiago Duarte Jul 21 '14 at 13:12
  • sorry, I don't why it didn't show up but try now. – Edward Jones Jul 21 '14 at 13:24
  • Which file is the problem one? I usually find when adding a script breaks something else on the page it is a loading order problem or there is an error in the script being added (which will break subsequent JS on the page) – John-M Jul 21 '14 at 13:26
  • don't know if embedding scripts like that outside the head section is much of a good practice, but that aside, have you tried any browser dev tool for script error messages? – Tiago Duarte Jul 21 '14 at 13:35
  • 1
    I had an issue with something loading before the ribbon the other day it didn't like either -- I fixed it by using ExecuteOrDelayUntilSriptLoaded like you have done, but instead of waiting for SP.js I had to use sp.ribbon.js – John-M Jul 22 '14 at 1:20
1

I too think this is an out of order script loading. Although: this is the first time I'm hearing about jQuery interfering with core.js and others. Because CEWP are inserted into the Body other page - thus after the HEAD script files - is what makes doubt this is a timing issue. SP (2013... And maybe 2010 too) uses a global variable called $, so maybe there is something inique in your setup that is causing jQuery to interfer with SP. If you can't put the scripts in the Master Page, as the other solution suggested, and defer attribute does not help, then try to run the following code right after jQuery loads:

jQuery.noConflict();

This should set back the $ variable to what it was prior to jQuery changing it.

Your code should already handle this and not depend on a global variable called $.

0

I wouldn't say disable, but it can block it from being loaded properly.

If there occur syntax errors and such in one or more files then yes, it could potentially "disable" core.js - but it depends on the version of SharePoint ( or ?)

First I would suggest that you check the console log in IE using the WebDeveloper tool (F12) to see if any javascript related errors are thrown.

If that doesn't tell you anything, then try removing them one by one until it starts working again. If it doesn't start working again before all of them are removed then try with older versions of the javascript files.

0

you are trying to add multiple scripts to a loading page, which will conflict with other scripts.

my advice is to add them to the master page, or if you want to use them in a single page, at least add them to the PlaceHolderAdditionalPageHead of the current page, which is sequentially after core.js

if you insist in having them in the CEWP, try defer

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.