8

trying to fix the issue where on an IOS device the keyboard disrupts fixed elements.

When clicking on a CKEditor text area, my aim is to set the style of that fixed element back to fixed.

Not sure how to detect the CKEditor being focused however.

Nothing I have tried has worked, here is the basic though:

http://jsfiddle.net/B4yGJ/180/

CKEDITOR.replace('editor1');

$('#editor1').focus(function() {
  alert('Focused');
});
Lovelock
  • 7,689
  • 19
  • 86
  • 186

3 Answers3

15

CKEditor has a custom focus event, that will be useful to you. See the docs here: http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-focus

You could use it like this for example:

CKEDITOR.on('instanceReady', function(evt) {
    var editor = evt.editor;
    console.log('The editor named ' + editor.name + ' is now ready');

    editor.on('focus', function(e) {
        console.log('The editor named ' + e.editor.name + ' is now focused');
    });
});

CKEDITOR.replace('editor1');

JSFiddle at http://jsfiddle.net/B4yGJ/181/

Joel Peltonen
  • 13,025
  • 6
  • 64
  • 100
1

The above solution didn't work for my case

Here is how I resolved after digging into the CKEditor documentation

if(CKEDITOR.instances['editor1'].focusManager.hasFocus) {
    alert('is focused');
}

Hope this helps someone with a similar issue.

dev_mustafa
  • 1,042
  • 1
  • 4
  • 14
-1

enter image description here Actually the jquery is hiding the your '#editor1' editor and creating new jquery editor.but still your triggering the hiding text editor(#editor). thats whay ur not getting alert box

Community
  • 1
  • 1
yugi
  • 834
  • 1
  • 15
  • 28