문제

사용자 정의 리본을 만들려고하고 있으며 프로젝트에서 JavaScript 파일을 만들었습니다.

여기에 이미지 설명 질문은 JavaScript 파일을 가져 오려면 <CustomAction> 태그를 사용할 수 있음을 알아낼 수있었습니다.

<CustomAction Id="Ribbon.Library.Actions.Scripts"
 Location ="ScriptLink" ScriptSrc="/_layouts/MyJSFile.js" />
.

이제 내 Elements.xml가 다음과 같습니다 :

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="Ribbon.Library.Actions.Scripts" Location="ScriptLink"
                ScriptSrc="/_layouts/CustomRibbonButton/JavaScript1.js" />

    <CustomAction
    Id="Ribbon.Library.Actions.AddAButton"
    Location="CommandUI.Ribbon"
    RegistrationId="101" RegistrationType="List"
    Title="Add a Ribbon Button">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition
          Location="Ribbon.Library.Share.Controls._children">
                    <Button Id="Ribbon.Library.Share.NewRibbonButton"
            Command="NewRibbonButtonCommand"
                    Image16by16="_layouts/15/images/placeholder16x16.png"
                    Image32by32="_layouts/15/images/placeholder32x32.png"
                                    LabelText="Hello World"
            TemplateAlias="o2" />
                </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
                <CommandUIHandler
          Command="NewRibbonButtonCommand" 
          CommandAction="javascript:getFiles()" />
            </CommandUIHandlers>
        </CommandUIExtension>
    </CustomAction>
</Elements>
.

IE Developer Tools의 네트워크 탭에서 내 페이지를로드 할 때 Path /_layouts/customribbonbutton/javascript1.js를 찾을 수없는 404 오류가 표시 될 수 있습니다.<CustomAction> 태그를 다음과 같이 업데이트했습니다.

<CustomAction Id="Ribbon.Library.Actions.Scripts" Location="ScriptLink"
                ScriptSrc="/_layouts/JavaScript1.js" />
.

그러나 나는 서로 다른 경로에 대해서도 아직 동일한 404 오류가 발생합니다.

여기서 뭘 잘못하고 있니?

도움이 되었습니까?

해결책

You need to append 15 to _layouts i.e /_layouts/15 in order to get hold of the file as you are working on SP 2013.

UPDATE

Put the javascript file under CustomRibbonButton folder in your project and use /_layouts/15/CustomRibbonButton/JavaScript1.js. The hive folder for SharePoint 2013 is 15. It used to be 12 for MOSS and 14 for SP 2010. This needs to be used explicitly as SP 2013 also supports solutions which are 2010 based and if you don't mention 15 in your code, then it will look for the file in 14 hive.

다른 팁

Add the following between the <CommandUIExtension> open and close tag

<CommandUIHandler
                    Command="NewRibbonButtonCommand"
                    CommandAction="javascript:Convertion();"
                    EnabledScript="javascript:enable();"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top