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:
1 2 3 4 5 6 7 |
tinyMCE.init({ selector: "textarea#mceEditorID", }); if ( typeof tinyMCE != 'undefined') { tinyMCE.EditorManager.execCommand('mceFocus', true, 'mceEditorID'); tinyMCE.EditorManager.execCommand('mceRemoveEditor', true, 'mceEditorID'); } |
Using with AJAX:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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); } }); |