11

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

2 Answers 2

18

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

4
  • Sorry for late reply. This fixed it. Thanks! :)
    – horgen
    Sep 20, 2010 at 7:05
  • helped me out when i called my ckeditor directive ckeditor , had to change it to ckEditor ==> ck-editor thanks
    – Jony-Y
    Mar 3, 2015 at 17:12
  • Please explain in details i did not get.
    – Soyab Badi
    Jul 14, 2016 at 11:47
  • @horgen I have multiple ckeditor in one page how can i fix the same issue raised once the page load
    – Mukesh S
    Nov 18, 2016 at 11:23
3
<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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.