I have specific requirements from my client that he wants to add some additional Ribbon Button "but only" via JavaScript (including EnableScript reading value from some other list). They don't want to deploy anything to SharePoint server.
So I know how to that via recommended way
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="HelloWorldExample"
Title="Hello WorldExample"
Location="CommandUI.Ribbon"
RegistrationType="List"
RegistrationId="101">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button Id="Ribbon.HelloWorldExample"
TemplateAlias="o1"
Command="HelloWorldExample"
LabelText="Hello world Example"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="HelloWorldExample"
CommandAction="javascript:alert('Hello world Example from ribbon !');"
EnabledScript="javascript:
function getStatus()
{
//check something
}
return false;" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
But how to accomplish this just via JavaScript/jQuery?