Rahul Yadav
Rahul Yadav

Reputation: 3217

CKEditor uncaught type error

I am trying to run

CKEDITOR.instances.textareaid.setReadOnly(true);

or

CKEDITOR.instances["textareaid"].setReadOnly(true);

I get an error in the console saying

Uncaught TypeError: Cannot read property 'setReadOnly' of undefined

However if I run the same statements in the console, it executes without error.

If I put a debugger before the statements and inspect the CKEDITOR object, the instance is present, still it throws the error.

Upvotes: 2

Views: 1569

Answers (1)

Ganesh Putta
Ganesh Putta

Reputation: 2681

Try this sample
https://sdk.ckeditor.com/samples/readonly.html
This is may be that your ckeditor is not fully loaded. below event fires once the editor is fully loaded, so is probably where you would like to tie into. try this may be this will help u

if ( CKEDITOR.status == 'loaded' ) {
    // The API can now be fully used.
     CKEDITOR.instances["textareaid"].setReadOnly(true);
}
   // Or 
CKEDITOR.on("instanceReady", function(event)
{
   CKEDITOR.instances["textareaid"].setReadOnly(true);
});

Upvotes: 3

Related Questions