Created
April 25, 2019 07:47
-
-
Save wictorwilen/9b9c92e44fdad45c2e027bb0802aefe4 to your computer and use it in GitHub Desktop.
requirejs issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = "https://contoso.sharepoint.com/sites/classic/SiteAssets/test" | |
var context = SP.ClientContext.get_current() | |
var site = context.get_site() | |
var actions = site.get_userCustomActions(); | |
context.load(site) | |
context.load(actions) | |
context.executeQueryAsync( | |
function () { | |
var newAction = actions.add(); | |
newAction.set_description('abc123') | |
newAction.set_location('ScriptLink') | |
var scriptBlock = 'var headID = document.getElementsByTagName("head")[0]; var newScript = document.createElement("script"); newScript.type = "text/javascript";newScript.src = "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.22/require.min.js"; newScript.setAttribute("data-main", url);headID.appendChild(newScript);'; | |
newAction.set_scriptBlock(scriptBlock) | |
newAction.update() | |
context.executeQueryAsync( | |
function () { | |
console.log("Success") | |
}, | |
function () { | |
console.log('Error') | |
}) | |
}, | |
function () { | |
console.log('Error') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment