uncaught exception: [CKEDITOR.editor] The instance already exists

限于喜欢 提交于 2019-12-04 17:48:36

问题


I've included the CKEditor on my site. Everything works even though I get this JS error:

uncaught exception: [CKEDITOR.editor] The instance "simple_editor" already exists.

The code below is contained inside a PHP file which I include where ever I want the editor. I only have one instance of the editor per page.

<textarea class='ckeditor' id='simple_editor' name='simple_editor'>".$page_content."</textarea>";

<script type="text/javascript">
 CKEDITOR.replace( 'simple_editor',
 { 
  height: '110px',
  toolbar :
  [
   ['Link','Unlink'],
   ['Styles','Format','Font','FontSize'],
   ['Bold','Italic','Underline','Strike'],
   ['TextColor','BGColor'],
   ['NumberedList','BulletedList','Outdent','Indent']
  ]
 }); 
</script>

After some googling I've seen people posting some solution which dosnt work.

if (CKEDITOR.instances['simple_editor']) { delete CKEDITOR.instances['simple_editor'] };
if (CKEDITOR.instances['simple_editor']) { CKEDITOR.instances['simple_editor'].destroy(); }

Anyone know what to do? :S


回答1:


remove class='ckeditor' as it's triggering the automatic replacement system.




回答2:


<textarea id="textarea1" name="textarea1" runat="server" ></textarea>
<script>

$(document).ready(function () {

            loadEditor('<%= textarea1.ClientID %>');
        });

        function loadEditor(id) {
            var instance = CKEDITOR.instances[id];
            if (instance) {
                CKEDITOR.remove(instance);
            }
            CKEDITOR.replace(id, { toolbar: 'Basic' });
        }

</script>


来源:https://stackoverflow.com/questions/3606681/uncaught-exception-ckeditor-editor-the-instance-already-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!