admin 发表于 2021-4-18 20:10:06

【KindEditor】提交时内容为空?

try {
    var editor;
    KindEditor.ready(function (K) {
      editor = K.create('textarea', {
            width: "100%",
            resizeType: 1,
            pasteType: 1,
            allowPreviewEmoticons: true,
            afterBlur: function () { this.sync(); },
            items: [
                'source', '|', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'link', '|','clearhtml']
      });
    });
} catch (e) { console.log(e); }

经检验,仍然提交为空。
查了资料,afterBlur: function () { this.sync(); }即可,但实际并非如此。

经过不断测试,才发现原来提交为空的原因是只有当文本框内容发生改变时,afterBlur: function () { this.sync(); }才起到作用,于是在提交事件发生增加:
editor.sync();
其实editor是try内定义的,发现可以提交kindeditor内容了,既使未做任何的改动前提下,也是可以正确提交的。
页: [1]
查看完整版本: 【KindEditor】提交时内容为空?