Dynamically textarea with TinyMce editor

Add this function to you JavaScript:

function textarea_to_tinymce(id){
    if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
        tinyMCE.execCommand('mceAddControl', false, id);
    }
}

then when you create the textarea dynamically call it and pass the textarea’s id to it.

Just make sure TinyMCE is loaded on that page before or it won’t work.

Leave a Comment