This is a migrated thread and some comments may be shown as answers.

[Solved] Replacing Parent Element HTML

1 Answer 160 Views
Editor
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 10 Apr 2008, 02:03 PM

Hi

I know I can replace HTML text as follows:

var theSelectionObject = editor.getSelection();
editor.pasteHtml('<span class="myNewClass">' + theSelectionObject.getHtml() + '</span>')


However, if I want to replace the text of the parent element, how would I do it? I know I can get a reference to the parent element as follows, but cant find a setHTML method?

var theSelectionObject = editor.getSelection();
var theSelectedElement = theSelectionObject.getParentElement();

theSelectedElement.setHTML('blah blah');

Can somebody point me in the right direction.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 10 Apr 2008, 02:24 PM
Hello David,

I am not quite sure what your scenario is but you can try to use the innerHTML property of the editor.getSelection().getParentElement() object:

<telerik:radeditor runat="server" Language="de-DE" ID="RadEditor1"></telerik:radeditor>
<input type="button" value="Paste Content" onclick="InsertSpan();return false;" />
<script type="text/javascript">
function InsertSpan()
{                 
  var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to the editor
  var theSelectionObject = editor.getSelection();
  var theSelectedElement = theSelectionObject.getParentElement();
  theSelectedElement.innerHTML = 'test';
}
</script>  

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
David
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or