未捕获的异常:[CKEDITOR.editor] 实例已存在

发布于 2024-09-16 11:31:52 字数 910 浏览 4 评论 0原文

我已在我的网站上添加了 CKEditor。即使我收到此 JS 错误,一切仍然有效:

未捕获的异常:[CKEDITOR.editor] 实例“simple_editor”已存在。

下面的代码包含在一个 PHP 文件中,我将其包含在我想要的位置编辑。我每页只有一个编辑器实例。

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

经过一番谷歌搜索后,我看到人们发布了一些不起作用的解决方案。

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

有人知道该怎么办吗? :S

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的十字路口 2024-09-23 11:31:53

删除 class='ckeditor' 因为它会触发自动替换系统。

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

少女净妖师 2024-09-23 11:31:53
<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>
<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文