Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using 2 button in custom tab and each button has a .js file to load . Could you please say me how to use 2 .js file in the same element .xml and here is my code for element xml

            Template="Ribbon.Templates.CustomTabTemplate">
            <Controls Id="Ribbon.SCustomTab.CustomTabGroup.Controls">
              <Button
                Id="Ribbon.CustomTab.CustomTabGroup.Button1"
                Command="CustomTab.Button1"
                Sequence="15"
                Image32by32="/_layouts/images/DocumentTab/Button.jpeg"
                LabelText="Button"
                TemplateAlias="Button"/>
              <Button
                Id="Ribbon.CustomTab.CustomTabGroup.Button2"
                Command="CustomTab.Button2"
                Sequence="17"
                Image32by32="/_layouts/images/DocumentTab/Button2l.jpeg"
                LabelText="Button2"
                TemplateAlias="Butt2"/>                

            </Controls>
          </Group>
        </Groups>
      </Tab>
    </CommandUIDefinition>
    <CommandUIDefinition Location="Ribbon.Templates._children">
      <GroupTemplate Id="Ribbon.Templates.CustomTemplate">
        <Layout
          Title="FiveLarge"
          LayoutTitle="FiveLarge">
          <Section Alignment="Top" Type="OneRow">
            <Row>
              <ControlRef DisplayMode="Large" TemplateAlias="Button1" />
            </Row>
          </Section>
          <Section Alignment="Top" Type="OneRow">
            <Row>
              <ControlRef DisplayMode="Large" TemplateAlias="Button2" />
            </Row>
          </Section>            
        </Layout>
      </GroupTemplate>
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler
      Command="CustomTab.Button1"
      CommandAction="javascript:Convertion();"
       EnabledScript="javascript:enable();"/>
    <CommandUIHandler     
      Command="CustomTab.Button2"
      CommandAction="javascript:Convertion1();"
       EnabledScript="javascript:enable();"/>

  </CommandUIHandlers>
</CommandUIExtension>

ScriptSrc="/_layouts/DocumentTabTwo/Button2.js"/>

Here in the above code the command action attribute of 2 buttons are having method convertion() in button 1.js file . and conversion1() methods in the button 2 .js file . Can any one say me how to add these 2 js file in element .xml Is the method which I did is correct or any changes to be made

Regards, Zakeer Ahamed.S

share|improve this question

1 Answer

You can reference an external js file like:

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

This will ensure the functions from the file are accessible from your CommandUIHandler

share|improve this answer
Thanks for this post and thanks for the answer :) – Dingo2600 Jan 10 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.