在CKEditor的,我知道,在“正常模式”,我们可以使用下面的代码检测到任何内容的变化:如何检测的CKEditor源模式的改变事件
ckeditor.on('change',function(e){
console.log("ckeditor on change");
});
但是如果我切换到源模式下,事件不会触发。
如何检测源视图的on change事件?
在CKEditor的,我知道,在“正常模式”,我们可以使用下面的代码检测到任何内容的变化:如何检测的CKEditor源模式的改变事件
ckeditor.on('change',function(e){
console.log("ckeditor on change");
});
但是如果我切换到源模式下,事件不会触发。
如何检测源视图的on change事件?
The CKEditor 4 documentation告诉变化的事件将不会源模式被解雇。
来自文档的示例适用于我。它将侦听器绑定到模式事件。当模式改变时会被解雇。当它更改为源时,将侦听器附加到编辑器。
editor.on('mode', function() {
if (this.mode === 'source') {
var editable = editor.editable();
editable.attachListener(editable, 'input', function() {
// Handle changes made in the source mode.
});
}
});
看一看这个问题:http://stackoverflow.com/questions/5230839/detecting-changes-with-ckeditor –
感谢@Kicker的提示,对重点作品为源视图以及 –
第一种说法是错误的:目前CKEditor本身不会触发任何变化事件。你必须使用一些处理它的插件,但它只能在“正常模式”下工作。 – AlfonsoML