Dynamically textarea with TinyMce editor

I need to used TextArea with Wysiwyg editor.
That works when textarea is write on page ( Not dynamic , static ).. but my problem is for dynamically textarea.

My code :

add_action('admin_head', 'load_tiny_mce');
  function load_tiny_mce() {
     // The 'mode' and 'editor_selector' options are for adding
      // TinyMCE to any textarea with class="tinymce-textarea"
      wp_tiny_mce(true, array(
          'mode' => 'specific_textareas',
         'editor_selector' => 'tinymce-textarea'
     ));
 }

I added textarea with javascript code when i push a button.
textareas is basic not with wysiwyg editor … ! I think i need to bind function … but how to !

I hope, you understand me .. !

Regards

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

any reply button on the comments is automated like :

<a class="comment-reply-link"
href="/post_url/?replytocom=187#respond" rel="nofollow noreferrer noopener"
onclick="addComment.moveForm("comment-" + id , id , "respond",
response) >Beantwoorden</a

>

as far as i have found now, you can not change the onclick event to some function in where you could add this execCommand.

Maybe this page helps you:

http://codex.wordpress.org/Function_Reference/comment_reply_link


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x