使用ckeditor“key” CKEDITOR.instances.editor.on('key',function(e){ [英] Use of ckeditor "key" CKEDITOR.instances.editor.on('key', function (e){

查看:473
本文介绍了使用ckeditor“key” CKEDITOR.instances.editor.on('key',function(e){的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到有关如何为CKEDITOR 4实现事件处理程序的问题。我可以使用这个代码来获取关键的数据,但是在加密之后似乎无法获得数据:

  CKEDITOR.instances.editor.on('key',function(e){
document.getElementById(预览)。innerHTML = CKEDITOR.instances.editor.getData();
});

所以当我在文本编辑器字段中输入像aaa这样的字符串时,第一个字符永远不会牵强。所以我的div id =预览只会显示aa。我已经重复了e对象,这是非常复杂的,但是没有什么可以帮助我解决这个问题。



我也没有看到其他人写这个。在CKEDITOR中似乎没有一个keyup事件,尽管我看到它写的很多。 keyup必须在旧版本中?



我希望我已经清楚地说明了我的问题。

解决方案

这样做:

  CKEDITOR.instances ['editor']。on('contentDom' ,function(){
CKEDITOR.instances ['editor']。document.on('keyup',function(event){
document.getElementById(preview)。innerHTML = CKEDITOR.instances。 editor.getData();
});
});

我稍等一下,检查为答案,以防其他人愿意贡献。 p>

I realize there are questions about how to implement an event handler for CKEDITOR 4. I am able to use this code to get the key-down data, but I can't seem to get the data after a key-up:

CKEDITOR.instances.editor.on('key', function (e){
    document.getElementById("preview").innerHTML = CKEDITOR.instances.editor.getData();
});

So when I type a string like "aaa" into the text editor field, the first character is never fetched. So my div id="preview" will only show "aa". I've iterated over the e object, which is quite complex, but nothing there strikes me as useful to solving this.

I also don't see other people writing about this. There doesn't seem to be a "keyup" event in CKEDITOR, though I see it written about a lot. "keyup" must have been in older versions?

I hope I have clearly stated my problem.

解决方案

This works:

CKEDITOR.instances['editor'].on('contentDom', function() {
    CKEDITOR.instances['editor'].document.on('keyup', function(event) {
        document.getElementById("preview").innerHTML = CKEDITOR.instances.editor.getData();
    });
});

I'll wait a bit before checking as answer, in case others would like to contribute.

这篇关于使用ckeditor“key” CKEDITOR.instances.editor.on('key',function(e){的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆