Martin Fisher
Martin Fisher

Reputation: 81

Text in TinyMCE textarea hidden in HTML Mode on click, ok in Visual mode

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'
        )
);

Upvotes: 2

Views: 857

Answers (2)

kaiser
kaiser

Reputation: 22363

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 );
}

Upvotes: 0

Thariama
Thariama

Reputation: 50840

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.

Upvotes: 0

Related Questions