tags:

views:

668

answers:

2

I have a DIV and a Load button on my page and when I click in Load button the jQuery loads a HTML from another file, this HTML file have texteareas and start tinymce.

Ex:

<script language="Javascript">
function loadForm() {
    $("#myContent").load("HTMLFile");
}

function goback() {
    $("#myContent").load("Another HTML File Without TINYMCE");
}
</script>

<div id="myContent"></div>
<input type="button" value="Load" onclick="loadForm()"/>

HTMLFile:

<textarea id="myText" class="tinymce"></textarea>
<input type="button" value="Cancel" onclick="goback()"/>
<script language="Javascript">
$("textarea.tinymce").tinymce({
    // Configurations here
});
</script>

The problem: When I click in Load button on my page the tinyMCE works, but after this if I click in Cancel button and after in Load button again the tinyMCE don't load more, only in first time.

Any tips?

+2  A: 

I would suggest adding the callback function of the load method to initialize the tineMCE editor.

 function loadForm() {
    $("#myContent").load("HTMLFile", {}, function(){
        $("textarea.tinymce").tinymce({
            // Configurations here
         });

    });
 }

So the HTMLFile will NOT have any script.

Vincent Ramdhanie
Thank you, this resolved my problem.
Cesar
A: 

You save me atleast 8 hours thank you very much

Hello to you