Detect focus of CKEditor

送分小仙女□ 提交于 2019-12-07 02:28:39

问题


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');
});

回答1:


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/




回答2:


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

来源:https://stackoverflow.com/questions/25838738/detect-focus-of-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!