Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor .focus() in instanceReady event is not working

I am having problems in setting the focus in instanceReady event of CKEditor 3.4.1. I have already tried the following two ways but both of them are not always working.

CKEDITOR.on('instanceReady', function(e) { CKEDITOR.instances.editor1.focus(); });


CKEDITOR.replace('editor1',
{
    on :
    {
        instanceReady : function( ev )
        {
            ev.editor.focus();
        }
    }
} );
like image 241
Thurein Avatar asked Apr 12 '11 19:04

Thurein


3 Answers

or maybe try this, this is much simpler:

use startupFocus : true

so your code should look like this:

CKEDITOR.replace('editor1',
{
    startupFocus : true,
...
like image 142
GianFS Avatar answered Sep 20 '22 18:09

GianFS


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();
        }
    }
} );
like image 41
mcgrailm Avatar answered Sep 23 '22 18:09

mcgrailm


CKEDITOR.instances['instance-name'].on('instanceReady', function (event) {
            CKEDITOR.instances['instance-name'].focus();
        });
like image 38
texian Avatar answered Sep 22 '22 18:09

texian