0

We have a custom ribbon button and we have added code to refer JS file in it. The ribbon button is bound to content type.

<CustomAction
Id="MyProject.RibbonButton"
Location="ScriptLink" 
ScriptSrc ="~sitecollection/Style Library/JS/MyProjectRibbonButton.js"/>

But MyProjectRibbonButton.js file is loaded on all the pages - site settings, home page - where the ribbon button is not event visible.

What is the cause of this issue?

Edit 1:

From Danny's comment below it seems that Location="ScriptLink" makes it load on all the pages. Any way I can make it load on only those pages where ribbon button is present?

7
  • 2
    It is not an issue, since SP2010 the CustomAction type ScriptLink is intended to load on all pages. Very powerful, alas does not execute on Microsofts Modern Experiences Dec 20, 2016 at 9:41
  • @Danny'365CSI'Engelman: Any way I can make it to load on only those pages where ribbon button gets loaded?
    – Naveen
    Dec 20, 2016 at 10:01
  • Show custom action in ribbon for only one list - check this link. You need to modify accordingly. Dec 20, 2016 at 10:05
  • @GautamSheth: I want to load the JS file where the ribbon button is present. As of now it loads across all the pages. Your link is for loading ribbon button and not JS file.
    – Naveen
    Dec 20, 2016 at 10:14
  • @Naveen, no, a ScriptLink loads on all pages --period-- Have you read the Microsoft documentation about CustomActions? Dec 20, 2016 at 10:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.