When you click on an item, the tinymce editor is added to the textarea. When I click on another element, I want tinymce to be killed and no trace of it remains on the page, but I can’t figure out how.

tinyMCE.get('content').remove(); 

Such a construction (above) roughly kills the editor, but looking at the error console, I notice that autosave works, which does not find the necessary elements on the page and causes an error. Also, when the editor is “reapplied” to textarea (id = content), the editor appears, but the text field is empty, and when you click on the HTML button, a modal window opens in which there is the necessary html code located in <textarea id = "content"> </ textarea>

    1 answer 1

    Also asked this question. The answer found on their website. In general, if briefly, then for the correct removal:

     if(tinyMCE.get('content')) { tinyMCE.execCommand('mceFocus', false, 'content'); tinyMCE.execCommand('mceRemoveControl', false, 'content'); } 

    And to create:

     tinyMCE.execCommand("mceAddControl", true, "content"); 

    A chip with a focus when deleting, if I'm not mistaken, is needed only for Explorer 6 version. Although I want to disable my website for the explorer 6 altogether in the future (i.e., not the whole site, but only its separate js-part), but left it just in case

    • Thank! As it turned out, this thing: tinyMCE.get ('content'). Remove (); - also works as it should, I just didn’t call init correctly ( hashcode.ru/questions/97315/jqgrid-tinymce - this is how to call the correct answer (jqgrid and tinymce)) - Nikoole
    • Do you call the init function there on every click (i.e., editing the line)? If so, then you can not do this. You can just call it once and that's it. And when I click on a table row (if I understood correctly, I have never worked with jqgrid and therefore I don’t know what it is) just do the following: tinyMCE.execCommand ('mceSetContent', tinyMCE.get ('content'), 'the text you need show '); This will load the client’s computer much less. This is just a tip. Of course, you can do without it. - Dobby007