Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a div that is part of a custom web part. Once a user clicks an edit-button I want the div to turn into a rich text field to allow the user to edit the contents as they would edit any rich text field in a page.

Currently I'm able to create the rich text field using:

RTE.Canvas.makeRegionEditable($('editorDiv')[0]);

But when the user tries to insert an ordered or unordered list (or apply indentation) from the ribbon the dom breaks. The rich text editor element is moved up two nodes in the hierarchy and some of the surrounding dom nodes are duplicated.

How can I fix this?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

It seems I have to have an empty div below the div that will become a rich text editor field.

If my dom looks like this:

<div class="editorContainer">
    <div></div>
</div>

And I call:

RTE.Canvas.makeRegionEditable($('editorContainer').children()[0]);

I get the behaviour described in the comment above. However if I insert an additional div in the html like so:

<div class="editorContainer">
    <div></div>
    <div></div>
</div>

It works fine. Why it would be required I don't know and I couldn't find any documentation on it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.