开发者

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

开发者 https://www.devze.com 2023-01-14 11:31 出处:网络
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.

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(开发者_如何学Go '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


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


<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消