Dynamic TinyMCE ( with ajaxForm )
Ok, this took me forever, therefor I thought to put it here. This is how you deal with TinyMCE 4 textareas when posting it's content dynamically:
Setup tinymce the regular way:
tinymce.init({ mode: 'textareas', });
Handle the form submission with jquery.form.js:
$('#BlockForm_1').ajaxForm({ // DON"T use the target option!!! Handle it yourself in the succes callback // target: '#BlockForm_1', beforeSerialize : function(arr, form, options) { // force tinymce to update content from it's magical iframe to your bare metal textarea tinyMCE.triggerSave(); // remove the textarea from tinymce's internal before it is replace/removed by you tinyMCE.execCommand('mceRemoveEditor', false, 'BlockBody_{$uuid}'); return true; }, success : function(data) { // replace the form's internals with the ones you received back from the application $('#BlockBody_1').html(data); // register your textarea with tinymce again tinyMCE.execCommand('mceAddEditor', false, 'BlockBody_1'); } });














