在我的页面中,我有多个CKEditor 4实例,页面中的其他内容都是通过JQuery和JQuery UI处理的,所以我宁愿使用相同的API样式来操作编辑器。每个实例都使用相同的类sarat_jquery_ckeditor_nostyles标记,我使用它的JQuery插件攻击CKEditor。到现在为止还好。
现在我需要拦截对内容的更改。我想我应该使用the blur event and the technique explained here:
到目前为止我的密码..。在文档准备就绪时,我需要:$('.sarat_jquery_ckeditor_nostyles').ckeditor(config).ckeditor(callback);
当然还有:
function callback (textarea) {
$(this).blur(function() {
newcontents = $(this).html();
alert (newcontents);
});
我看到编辑器绘制时在调试器中调用我的回调,但模糊函数从未被调用。(在那里,我会放置一个ajax调用,并将html发布到数据库、服务器端)。
不幸的是,在这种情况下,我不能为CKEditor使用较新的内联样式(这对我来说非常有用)。
发布于 2015-08-21 14:10:09
您可以对每个编辑器使用模糊事件,如下所示:
$.each(CKEDITOR.instances, function(i) {
var editor = CKEDITOR.instances[i];
editor.on('blur', function() {
if (editor && editor.window && "getFrame" in editor.window) {
var html = $(editor.window.getFrame().$).contents().html();
}
});
});
https://stackoverflow.com/questions/32142284
复制相似问题