Hi,
I have the following function inserted in my RichText Commands.js file:
RadEditorCommandList["InsertAccordion"] = function (commandName, editor, args) {
var selectedHtml = editor.getSelectionHtml();
var newHtml = "<div class=\"accordion-rte\">" + selectedHtml + "</div>";
editor.pasteHtml(newHtml);
};
It should wrap the selected content in a <div> with the css class "accordion-rte".
Simply enough I thought... But when I have a text like:
<h2>Heading 2</h2>
<p>Some text</p>
<p>Heading 2.1</p>
<p>put some text here for paragraph 2.1</p>
<p>Heading 2.2</p>
<p>put some text here for paragraph 2.2</p>
<p>Some other text</p>
<p> </p>
and I select in design mode the text from "Heading 2.1" to "put some text here for paragraph 2.2" and then exucute my script the result is:
<h2>Heading 2</h2>
<p>Some text</p>
<p>Heading 2.1</p>
<p>put some text here for paragraph 2.1</p>
<p>Heading 2.2</p>
<p>put some text here for paragraph 2.2</p>
<p>
<div class="accordion-rte"> </div>
</p>
<p>Some other text</p>
<p> </p>
while debugging I see the newHtml variable is containing the right value. It got messed up somewhere in the pasteHtml function.
Does anyone has a clue what's going wrong? and how I can get it to work?
Much appreciated,
Peter