Tuesday, July 10, 2012

Resolving ~ uncaught exception: [CKEDITOR.editor] The instance "myCKEditor" already exists.

Having added the CKEditor successfully to our web application, we see that it loads fine but during post-back we get a javascript error message as

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

The error states about the existence of the CKEditor in the browser. So, we have to get rid of the ones that already exists using the following method:

<script language="javascript" type="text/javascript">
    if (CKEDITOR.instances['myCKEditor']) { delete CKEDITOR.instances['myCKEditor'] };
    if (CKEDITOR.instances['myCKEditor']) { CKEDITOR.instances['myCKEditor'].destroy(); }
</script>

The above code will remove the existence of the ‘myCKEditor’ editor from the browser memory and recreates it thereby resolving the issue.

Happy Programming!!!

5 comments:

Unknown said...

Hi!

I'm fighting with the same problem, and i'm stucked. In which part of the code did you put this fragment?
I tried it serveral ways but didn't worked.

Any help would be good.

Thanks.
Ggy

Hemant said...

Hi Gabor,

Just add the above script fragment at the bottom of your page where you are using the CKEditor control. I know you might have changed the CKEditor instance name 'myCKEditor' in the above script matching with yours but just curious and wanted you double check just to make sure you have done that.

Thanks,
Hemant.

Anonymous said...

Works great! thanks!!!

RE.

Hemant said...

Glad to help you.

Thanks & Regards,
Hemant.

Anonymous said...

i love you man <3