easyui用KindEditor编辑器

<link href="~/Scripts/Kindeditor/themes/default/default.css" rel="stylesheet" />
<link href="~/Scripts/uploadify/uploadify.css" rel="stylesheet" />

<div class="fitem">
<div class="details_text" style="width: 700px; height: 500px; float: left;">
<textarea id="editor_id" style="height: 500px; width: 670px" name="content"></textarea>
</div>
</div>

<script type="text/javascript" src="~/Scripts/Kindeditor/kindeditor-all.js"></script>
<script type="text/javascript" src="~/Scripts/Kindeditor/zh-CN.js"></script>
<script type="text/javascript" src="~/Scripts/uploadify/jquery.uploadify.min.js"></script>
var kindeditor;
$(function () {
    //初始化图片上传控件
    KindEditor.ready(function (K) {
        kindeditor = K.create('#editor_id', {
            //uploadJson: '/Management/UploadPic?type=1&result=' + result + "&imgUrl=" + imgUrl + "&returnType=" + returnType,
            uploadJson: web_dir + '/Management/UploadPic?type=1',//指定上传文件的服务器端程序。
            allowFileManager: false,//true时显示浏览远程服务器按钮。
            pasteType: 1,//设置粘贴类型,0:禁止粘贴, 1:纯文本粘贴, 2:HTML粘贴

            //urlType,//指定编辑器的根目录路径。数据类型: String;默认值: 根据kindeditor.js文件名自动获取
            afterCreate: function () {//设置编辑器创建后执行的回调函数。
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
    });

    setTimeout(function () {
        getInfo(curId);
    }, 300)
})

出错的很大原因是编辑器没有渲染完DOM,就去发请求数据了,所以加了定时器,不行就改时间长点

//绑定值
kindeditor.html(unescape(msg.row_data.record.SugContent));
//获取值
var detailHtmlStr = escape(kindeditor.html());

猜你喜欢

转载自www.cnblogs.com/liufeiran/p/12893217.html