Question

When I load a page with a NicEditor and there is no text loaded, the NicEditor defaults to having a content of <BR>.

I added check after I create my editor instance.

        myNiceEditor.addInstance(niceEditTextAreaSelectorClientID);
        if(myNiceEditor.nicInstances[0].getContent() == "<BR>"){
            myNiceEditor.nicInstances[0].setContent('');
        }

However when the page is loaded my editor's content is now <P>&nbsp;</P>

Was it helpful?

Solution

Well, this is silly.

The solution is to repeat myself...

    myNiceEditor.addInstance(niceEditTextAreaSelectorClientID);
    if(myNiceEditor.nicInstances[0].getContent() == "<BR>"){
        myNiceEditor.nicInstances[0].setContent('');
        myNiceEditor.nicInstances[0].setContent('');
    }

OTHER TIPS

 editor.addInstance(editorId);
if(editor.nicInstances[0].getContent() == "<br>"){
    editor.nicInstances[0].setContent('');
}

You can also try the following code where editor is the id attribute of your html element:

if ( nicEditors.findEditor( 'editor' ).getContent() == "<br>" ) {
    nicEditors.findEditor( 'editor' ).setContent( '' );
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top