KindEditor使用过程中,用JQ提交表单时,获取不到编辑器的内容

首先要说明的是。在使用提交button直接提交时。编辑器的内容是能够正常获取的,而使用 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();}

});

});

这样,不管哪种方式提交都能够获取到编辑器的内容了



原文地址:https://www.cnblogs.com/slgkaifa/p/7181421.html