首先要说明的是,在使用提交按钮直接提交时,编辑器的内容是可以正常获取的,而使用 jq或js ,如$("#form").submit(),提交时,则编辑器的内容是无法获取的,这里在 kindEditor官方中提出的解决方案为:
在编辑器创建时,增加属性:afterBlur:function(){this.sync();}
这里看一个完整的实例:
var editor; KindEditor.ready(function(K) { editor = K.create('textarea[name="content"]', { themeType:'simple', resizeType : 1, allowPreviewEmoticons : false, allowImageUpload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'link'], afterBlur:function(){this.sync();} }); });
这样,无论哪种方式提交都可以获取到编辑器的内容了
在分享多多项目中的kindeditor.js已经修改,在265行增加词句:
afterBlur:function(){this.sync();},