2
votes

Custom wordpress form, using wp_editor, I create a Tinymce instance on the textarea.

Editor defaults to HTML but if I click into the editing area the contents disappear.

However if I switch to Visual mode, all works as expected, then switch back to HTML mode all works there too, maybe the click is being intercepted by TinyMCE?

Any clues please....

Thanks Martin

PS initializations are:

$settings = array(
        'wpautop' => true,
        'media_buttons' => false,
        'tinymce' => array(
                'theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen',
                'theme_advanced_buttons2' => '',
                'theme_advanced_buttons3' => '',
                'theme_advanced_buttons4' => '',
                'theme_advanced_resizing' =>  true,
                'width' => '600px'
        )
);
2

2 Answers

0
votes

Such problems (besides others) may arise when a hidden textarea (or other html element) is used to init a tinymce editor. Best way to avoid this is to make it visible just before you init the editor.

0
votes

I've taken a different approach and re-init the tinyMCE when switching between them. Attach it to an even handler:

var postContent = "Take Content from some hidden field, AJAX call, etc.";
if ( tinyMCE
    && tinyMCE.activeEditor
    && tinyMCE.activeEditor.id )
{
    tinyMCE.activeEditor.setContent( postContent, {} );
    tinymce.execCommand( 'mceRemoveControl', true, tinyMCE.activeEditor.id );
}