2

I am using Tiny MCE editor version : 3.5.7
I am using multiple instances of text editor on same page with unique IDs and I have wrapped these editors in a div to show and hide these editors. Everything was working fine. Now I want to clear the contents of the editor when user hide it (so that when it is displayed again the previous contents are removed). I tried to do it using tinyMCE.get('editorId').setContent(''), it works fine only once.... I mean once I have used the above function than I am unable to set or even get the contents of that editor instance. The structure that I have used is as follows:

<div id="parentDIV">
  <div id="1_editor">
  </div>
</div>

tinyMCE.init({
        mode: "exact",
        max_char: "2000",
        elements: "1_editor",
        // Setting up ToolBar
        theme: "advanced",
        theme_advanced_layout_manager: "SimpleLayout",
        theme_advanced_buttons1: "bold,italic,underline, strikethrough,     separator,justifyleft, justifycenter,justifyright,  justifyfull, separator,bullist,numlist,separator,fontselect ,fontsizeselect",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
    });

To show and hide the editor I doing something like this:

$('#parentDIV').hide();
$('#parentDIV').show();

Can anyone help please?

4

1 回答 1

0

我不完全确定为什么会发生这种情况。一种选择是如果编辑器在 dom 中移动。对您来说,明确关闭编辑器然后隐藏它们可能是更好的方法。

要关闭编辑器实例,请使用:

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

重新初始化使用

tinymce.execCommand('mceAddControl',true,'editor_id');
于 2012-10-25T08:34:21.417 回答