How to empty TINYMCE Editor content after AJAX action
We have share How to empty TINYMCE content after AJAX action with jQuery. Use the mceRemoveControl execCommand here.
I do this:
tinyMCE.init({ selector: "textarea#mceEditorID", }); if ( typeof tinyMCE != 'undefined') { tinyMCE.EditorManager.execCommand('mceFocus', true, 'mceEditorID'); tinyMCE.EditorManager.execCommand('mceRemoveEditor', true, 'mceEditorID'); }
Using with AJAX:
jQuery.ajax({ url: 'url', type: 'post', beforeSend: function () { }, complete: function () { }, success: function (html) { if (typeof tinyMCE != 'undefined') { tinyMCE.EditorManager.execCommand('mceFocus', true, 'mceEditorID'); tinyMCE.EditorManager.execCommand('mceRemoveEditor', true, 'mceEditorID'); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } });