質問

カスタムリボンを作成しようとしていると私のプロジェクトではJavaScriptファイルを作成しました。

ENTER IMENT Descriptionこちら

からこのこの質問私は、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 PageをIEにロードすると、IE開発者ツールの[ネットワーク]タブで[ネットワーク]タブにロードすると、Path /_layouts/customribbonbutton/javascript1.jsが見つからないことがわかります。<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