Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE.init not working on second click

In my page there is a list of buttons. Depending on the clicked button the same .php file is loaded with a different content for the <textarea>. Then TinyMCE is initialised and after that the content of TinyMCE is set.

However, this only works on the first click. When a user clicks a different button, the <textarea> is loaded, but TinyMCE is not initialised. I don't know why it's doing that, because it's the same script that is executed.

$("ul").on("click", "a.click-menu", function() {
    var id = $(this).attr("id");
    $(".inject").load("Including/modules/Pages/index.php?page="+id, function () {
        tinymce.init({selector:"textarea"});
    });
});

And this is index.php in a nutshell:

<?php

    echo '<textarea>'.$_GET['page'].'</textarea>';

?>
like image 292
user3821544 Avatar asked Feb 20 '26 23:02

user3821544


1 Answers

You should remove old TinyMCE and add new one to new controls...

Heres how it should be made

like image 195
Flash Thunder Avatar answered Feb 22 '26 12:02

Flash Thunder