Here is my code:
function OpenContentBuilder()
{
$.post("tools/tools_builder.php", {
_open_content_builder : 1
}, function(data)
{
$("#container").html(data);
// Go Back to Course Section List - Button
$("#course_builder_go_back").click(function()
{
tinyMCE.execCommand('mceRemoveEditor ', false, 'target_builder');
InitCourseContentList()
});
if (tinymce.editors.length < 1) {
tinymce.init({
mode : "none",
width : 680,
height : 300,
selector : "textarea#target_builder",
theme : "modern"
});
} else if (tinymce.editors.length > 0){
tinyMCE.execCommand('mceAddEditor', true, 'target_builder');
} else {
alert("Cannot load editor!");
}
});
}
The textarea is built in this line:
$("#container").html(data);
The html brought in for it looks like this:
<div>
<textarea id="target_builder" ></textarea>
</div>
the first time it loads, it works. If I hit the back button go somewhere else on the page, and come back (the entire page url never changes: it is done with ajax
), the textarea
is there, the editor is not.
When I do an alert
in the tinymce.editors.length > 0
test, it shows (on the second or more load).
I see many questions that reference this and say you have to remove and add the instance with the execCommand
. Am I using this correctly?