Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve the CKEDITOR.status "ready"?

Tags:

In my script, I wanted to wait for the CKEDITOR to be in state ready before I let my own instructions go their way. So I consulted the CKEDITOR API and wrote the following condition:

if(CKEDITOR.status == "ready"){  //execute my code when ready } 

However, the status never ever changes to from loaded to status. Apparently I didn even see any other state.

More task specific, I wanted to catch the moment when CKEDITOR has completed modifying the inline replacing of contenteditable="true". That's when I want to go ahead with my JS code.

Any clues?

like image 489
feder Avatar asked Aug 27 '13 09:08

feder


People also ask

How do I know if CKEditor is loaded?

// At the top of the script CKEDitor_loaded = false; // then later CKEDITOR. on('loaded', function(){ CKEditor_loaded = true; }); Instead of a global variable, you could also consider setting something inside CKEDITOR : CKEDITOR.

How do I get CKEditor value?

you can add the following code : the ckeditor field data will be stored in $('#ELEMENT_ID'). val() via each click. I've used the method and it works very well. ckeditor field data will be saved realtime and will be ready for sending.

What does CKEditor return?

will return a null value.

How do I call CKEditor?

click(function() { __text. hide(); if (editor) return; editor = CKEDITOR. replace("editor"); editor.


2 Answers

If you want to execute your code when the API is fully loaded, use CKEDITOR.loaded event:

CKEDITOR.on( 'loaded', function( evt ) {     // your stuff here } ); 

If you want to execute your code when any new instance is ready, use CKEDITOR.instanceReady event:

CKEDITOR.on( 'instanceReady', function( evt ) {     // your stuff here } ); 

If you want to execute your code when a particular instance is ready, then use CKEDITOR.editor.instanceReady event:

CKEDITOR.replace( 'editor', {     on: {         instanceReady: function( evt ) {             // your stuff here         }     } } ); 
like image 116
oleq Avatar answered Oct 01 '22 16:10

oleq


there's no ready status in CKEDITOR, you can use loaded like:

if ( CKEDITOR.status == 'loaded' ) {     // The API can now be fully used.     doSomething(); } 

or use instanceReady, like:

CKEDITOR.on('instanceReady', function(evt){     //ready   //do something }); 
like image 41
Sudhir Bastakoti Avatar answered Oct 01 '22 18:10

Sudhir Bastakoti