CKEditor键事件未正确更新文本 [英] CKEditor key event not updating text properly
本文介绍了CKEditor键事件未正确更新文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,当用户在CKEditor文本区域中键入内容时, CKEDITOR.instances.editor.on(key,function(e)
{
var preview = document.getElementById('some-div');
preview.innerHTML = CKEDITOR.instances .editor.getData();
});问题是,如果我键入Hello world,在div中出现Hello woll ,直到按下另一个键,d才会出现。我想在两个地方都有相同的内容。提前致谢! 解决方案我解决了以不同的方式处理关键事件。您可以在下面看到:
CKEDITOR.instances.editor.on('contentDom',function()
{
CKEDITOR.instances.editor.document.on('keyup',function(event)
{
var preview = document.getElementById('some-div');
preview .innerHTML = CKEDITOR.instances.editor.getData();
});
});
I have the following code to automatically update the content inside a div when the user types it inside a CKEditor textarea:
CKEDITOR.instances.editor.on("key", function(e)
{
var preview = document.getElementById('some-div');
preview.innerHTML = CKEDITOR.instances.editor.getData();
});
The problem is that if I type in "Hello world", in the div it appears "Hello worl" and the "d" doesn't appear until another key is pressed. And I would want the same content in both places. Thanks in advance!
解决方案 I solved it handling the key event in a different way. You can see it below:
CKEDITOR.instances.editor.on('contentDom', function()
{
CKEDITOR.instances.editor.document.on('keyup', function(event)
{
var preview = document.getElementById('some-div');
preview.innerHTML = CKEDITOR.instances.editor.getData();
});
});
这篇关于CKEditor键事件未正确更新文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文