[ACCEPTED]-CKEditor .focus() in instanceReady event is not working-ckeditor

Accepted answer
Score: 22

or maybe try this, this is much simpler:

use 1 startupFocus : true

so your code should look like this:

CKEDITOR.replace('editor1',
{
    startupFocus : true,
...
Score: 12

here you go my friend

CKEDITOR.replace('editor1',
{
    on :
    {
        instanceReady : function( ev )
        {
            CKEDITOR.instances.editor1.focus();
        }
    }
} );

or

CKEDITOR.replace('editor1',
{
    on :
    {
        instanceReady : function( ev )
        {
            this.focus();
        }
    }
} );

0

Score: 5
CKEDITOR.instances['instance-name'].on('instanceReady', function (event) {
            CKEDITOR.instances['instance-name'].focus();
        });

0

Score: 1

a bit late but:

CKEDITOR.replace( 'YourEditor', 
{ 
 on:
   {
     instanceReady : function( evt )
     {
       //Set the focus to your editor
       CKEDITOR.instances.YourEditor.focus();
      }
    }
}

works fine for me. Found 1 here

Score: 1

Best way to me,

  1. find the CKEditor instance, then
  2. trigger focus event

    The critical point is to focus instance in timeout

    for (var 3 instance in CKEDITOR.instances) {
    $timeout(function() { CKEDITOR.instances[instance].focus(); }); }

Note: I 2 found the instance with a for loop. You 1 may find better way to find the instance

Score: 1

Neither of the above answers worked for 2 me. Here is what I did for CHROME and it works 1 just fine:

CKEDITOR.instances['instance-name'].container.focus();
Score: 0

Dirty way (Make sure you read the comment 1 under my answer):

jQuery('.cke_wysiwyg_frame').contents().find('body').focus();

More Related questions