I have the below script for adding a formatted <H3> and <p> element into a SharePoint site page in edit mode:
<script type="text/javascript">
$(document).ready(function() {
$("button[name='addDom']").click(function() {
var domElement = $('<div><h3>Heading</h3></br><p>Text</p></div>');
$(this).after(domElement);
});
});
</script>
on the button click:
<button name="addDom" type="button">Click</button>
May I know how to incorporate this button click into the below XML file, so that when I click on the custom ribbon button, I am able to add the <h3> and <p> element to the site page.
<?xml version="1.0" encoding="utf-8" ?>
<branding xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<customaction Name="InsertRibComponentUI" Location="CommandUI.Ribbon" Sequence="30" removeCustomAction="false">
<commandUIExtension>
<![CDATA[<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Media.Controls._children">
<Button
Id="Ribbon.EditingTools.CPInsert.Media.RibUI"
Command="Ribbon.Command.InsertRibComponentUI"
Sequence="30"
Image16by16="/_layouts/15/1033/images/formatmap16x16.png?rev=33" Image16by16Left="-164" Image16by16Top="-270"
Image32by32="/_layouts/15/1033/images/formatmap32x32.png?rev=33" Image32by32Left="-102" Image32by32Top="-341"
Description="Insert Ribbon Button"
LabelText="Button"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Ribbon.Command.InsertRibComponentUI"
CommandAction="javascript:alert('Test');"/>
</CommandUIHandlers>
</CommandUIExtension>]]>
</commandUIExtension>
</customaction>
</branding>