Search code examples
ajaxtinymcewysiwyg

load page with tinymce (AJAX)


Im not having problem with loading the page using jQuery but when I load the page with textarea that should have tinymce dont show.

$.ajax({
type: "POST",
url: 'textarea.php',
data: {data: info},
async: false,
beforeSend: function() {
},
complete: function() {
},        
cache: false,
success:  function(result) {
  $('#form-area').html(result);
}
error: function(error) {
alert("Some problems have occured. Please try again later: " + error);
}

});


Solution

  • Looks like you should call the tinymce.init function right after the html code from the ajax request has been insered into the dom. You may alternatively call

    tinymce.execCommand('mceAddControl',true,'editor_id');
    

    You need to keep in mind that you should shut down the tinymce editor instance in case you want to reload the editor instance using ajax. Use in this case

    tinymce.execCommand('mceRemoveControl',true,'editor_id');