弘帝企业智能建站系统交流平台

 找回密码
 立即注册
查看: 1342|回复: 0

【KindEditor】提交时内容为空?

[复制链接]
发表于 2021-4-18 20:10:06 | 显示全部楼层 |阅读模式
try {
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            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内容了,既使未做任何的改动前提下,也是可以正确提交的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|弘帝企业智能建站系统 ( 皖ICP备07503252号 )

GMT+8, 2024-4-20 02:50 , Processed in 0.096153 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表