user2914191
user2914191

Reputation:

tinymce doesnt initiate editor again with dynamically loaded html

I have a div that contains HTML contents that gets loaded dynamically. Every time I fetch a page using $.ajax I execute a function that transforms .tinymce-basic into TinyMCE textareas.

function on_page_load(){
    jQuery('.tinymce-basic').tinymce({
         theme: "modern"
    });
}

The first time the page loads all works great, tinymce loads correctly and functions just fine. However, when I reload the contents using $.ajax and call on_page_load to re-initiate TinyMCE, it never gets initiated. I have the dynamically loaded <textarea class="tinymce-basic"></textarea> just sitting there, and nothing happens.

Why doesn't TinyMCE re-initiate again? Is this possible?

Upvotes: 0

Views: 464

Answers (1)

user2914191
user2914191

Reputation:

The solution was to call tinymce.remove(id) on every initiated instance. I assume when I attempted to re-initiate the same textarea ids it failed to do so because the ID already existed.

Upvotes: 3

Related Questions