I am trying to use a .js file to highlihgt nodes in a top navigation menu based on url of the current web. The javascript file is provisioned by a Module in a Empty SharePoint 2013 project item. The problem is that it never comes to my method. It seems sp.js is never loaded. I have used ExecuteOrDelayUntilScriptLoaded and LoadSodByKey methods like following:
LoadSodByKey("sp.js", function () {
$(function () {
//alert("sp.js loaded");
});
});
ExecuteOrDelayUntilScriptLoaded(function () { SP.UI.Workspace.add_resized(MyMethod); },
"sp.js");
function MyMethod() {
currentcontext = new SP.ClientContext.get_current();
currentweb = currentcontext.get_web();
currentuser = currentweb.get_currentUser();
rootWeb = currentcontext.get_site().get_rootWeb();
currentcontext.load(rootWeb, 'EffectiveBasePermissions', 'ServerRelativeUrl', 'Id');
currentcontext.executeQueryAsync(Function.createDelegate(this, ExecuteOnSuccess), Function.createDelegate(this, ExecuteOnFailure));
}
//and ExecuteOnSuccess , ExecuteOnFailure
thanks
_spBodyOnLoadWrapper()
manually, and perhaps try 'SP.js', although I don't think it should be case sensitive.