ckeditor内容的事件已更改 [英] Event for ckeditor content changed
问题描述
如果可能的话,我们如何更改ckeditor的内容?例如,打开页面时,某些文本已插入ckeditor的内容(又称为textarea)中.之后,我再输入一些内容或删除其中的一些文字.发生文本更改时,是否可以触发更改某个变量的事件?
If possible, how can we to the event of ckeditor's content being changed? For instance, there's some text already inserted into the ckeditor's content aka textarea when the page is opened. Afterwards I type something more or delete some of that text. Is there some event that's fired I can get to to change a variable when the text is changed?
我有常规的文本区域:
$("input,textarea").on("input", function () {
booleanvar= true;
});
在某处看到了可能的解决方案:
Saw a possible solution somewhere that had this:
$('.ckeditor').ckeditorGet().on('key', function (e) {
//some code
});
尝试过,但是没有用.是的,我知道我的ckeditor的textarea具有"ckeditor"作为其类,因此这不是其不起作用的原因.
Tried it, but didn't work. And yes I know my ckeditor's textarea has "ckeditor" as its class so that's not the reason for it not to work.
所以像那些例子,我可以用来了解ckeditor的某种文本更改事件吗?
So something like those examples I can use to get to some sort of textchanged event of ckeditor?
推荐答案
是的,即使您可以听,也有非常方便的change
.此处的文档: http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-change
Yes, there is the very handy change
even that you can listen to. Documentation here: http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-change
像这样使用它(将editor1更改为您的编辑器实例):
Use it for example like so (change editor1 to your editor instance):
CKEDITOR.instances.editor1.on('change', function() {
console.log("TEST");
});
这篇关于ckeditor内容的事件已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!