Hi
I'm trying to define a custom action in the ribbon for my list. When action gets invoked, I'd like to call my JS code. As long as the JS code is embedded within the CommandAction or EnabledScript attributes - all works fine, but when I try to load it through additional CustomAction element, all I get is blank page.
Here is my Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction ScriptSrc="Scripts/CustomRibbon.js" Location="ScriptLink" Sequence="1">
</CustomAction>
<CustomAction Id="CustomRibbonTab" Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">
<Button
Id="Ribbon.Items.New.RibbonTest1"
Alt="Test Button"
Sequence="5"
Command="Test_Button"
LabelText="Click me!"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png"
TemplateAlias="o1" />
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.List.ViewFormat.Controls._children">
<Button
Id="Ribbon.Items.New.RibbonTest2"
Alt="Test Button"
Sequence="5"
Command="Test_Button"
LabelText="Click me!"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png"
TemplateAlias="o1"
/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Test_Button"
CommandAction="javascript:processItem('{ListId}', getItemId());"
EnabledScript="javascript:isSingleItemEnabled();">
</CommandUIHandler>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
and here is actual content of JS file
function isSingleItemEnabled() {
return true;
//var items = SP.ListOperation.Selection.getSelectedItems();
//return (items.length == 0);
}
function getItemId() {
return '1234';
//return SP.ListOperation.Selection.getSelectedItems()[0].id;
}
function processItem(listId, itemId) {
}
So - nothing fancy. What am I doing wrong?
Greg