Vlad
Vlad

Reputation: 21

Uncaught [CKEDITOR.editor] The instance "html" already exists

I have a problem with loading CKEDITOR. I have made everything like described here: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Integration But anyway i'm getting an error (Google Chrome 4.x) Uncaught [CKEDITOR.editor] The instance "html" already exists. Here is my code:

<script type="text/javascript" src="/engine/jq.js"></script> 
<script type="text/javascript" src="/engine/cke/ckeditor.js"></script> 
<script type="text/javascript" src="/engine/cke/adapters/jquery.js"></script>

<textarea class="jquery_ckeditor" name="html" id="html" rows="10">text</textarea>
<script type="text/javascript">
    if (CKEDITOR.instances['html']) { CKEDITOR.remove(CKEDITOR.instances['html']); // with or without this line of code - rise an error }
    CKEDITOR.replace('html');
</script>

Upvotes: 2

Views: 11339

Answers (9)

user1305194
user1305194

Reputation: 7

Try this, it worked for me

var editor = CKEDITOR.instances["your_textarea"]; 
if (editor) { editor.destroy(true); }

Upvotes: 0

InkHeart
InkHeart

Reputation: 880

Try this, hope it works, it worked for me.

for(html in CKEDITOR.instances['html')

{

CKEDITOR.instances[html ].destroy();

}

http://dev.ckeditor.com/ticket/9862#no1

Upvotes: 0

Pierre
Pierre

Reputation: 41

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

Upvotes: 4

Furnica
Furnica

Reputation: 199

The solution that works for me: in an Ajax view, having two controls

@Html.TextAreaFor(model => model.offreJob.profile, new { @class = "input_text_area_nofloat", @style = "width:590px", @id = "ck_profile" })

and

@Html.TextAreaFor(model => model.offreJob.description_job, new { @class = "input_text_area_nofloat", @style = "width:590px", @id = "ck_description" })

I use the following script:

        <script>
        if (CKEDITOR.instances['ck_profile']) {
            delete CKEDITOR.instances['ck_profile'];
        }
        CKEDITOR.replace('ck_profile');

        if (CKEDITOR.instances['ck_description']) {
            delete CKEDITOR.instances['ck_description'];
        }
        CKEDITOR.replace('ck_description');
    </script>

Upvotes: 0

Mezi
Mezi

Reputation: 101

check this:

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

CKEDITOR.replace('html');

Upvotes: 7

Ken
Ken

Reputation: 51

using the jquery ckeditor adapter - I was able to reinitialize ckeditor textareas in ajax content using this function.

function initCKEditor() {
    $('.wysiwyg').ckeditor(function(e){
            delete CKEDITOR.instances[$(e).attr('name')];
        },{
            toolbar:
                [
                    ['Bold','Italic','Underline','Strike','-','NumberedList','BulletedList','-','Paste','PasteFromWord','-','Outdent','Indent','-','Link','-','Maximize','-','Source']
                ],
            skin: 'office2003'
        }
    );  
}

Upvotes: 4

Gordon Anderson
Gordon Anderson

Reputation: 29

http://ckeditor.com/blog/CKEditor_for_jQuery has a fix if you are using jQuery

// remove editor from the page $('textarea').ckeditor(function(){ this.destroy(); });

Upvotes: 1

Nealv
Nealv

Reputation: 6884

Your page has a html container, try renaming your textarea ?

<textarea class="jquery_ckeditor" name="editor" id="editor" rows="10">text</textarea>
<script type="text/javascript">
    CKEDITOR.replace('editor');
</script>

Upvotes: 0

Olly Hicks
Olly Hicks

Reputation: 1104

Same error, getting it with the jQuery adapter though. Check the class of the textarea. As far as i can tell all text areas with class 'ckeditor' are automatically converted to editors. So either don't bother setting it with javascript or change the class.

Upvotes: 1

Related Questions