easyui编辑器(kindeditor-4.1.10)


//1  重写kindedit    -建一个js文件 easyui_kindeditor.js

(function ($, K) {
    if (!K)
        throw "KindEditor未定义!";

    function create(target) {
        var opts = $.data(target, 'kindeditor').options;
        var editor = K.create(target, opts);
        $.data(target, 'kindeditor').options.editor = editor;
    }

    $.fn.kindeditor = function (options, param) {
        if (typeof options == 'string') {
            var method = $.fn.kindeditor.methods[options];
            if (method) {
                return method(this, param);
            }
        }
        options = options || {};
        return this.each(function () {
            var state = $.data(this, 'kindeditor');
            if (state) {
                $.extend(state.options, options);
            } else {
                state = $.data(this, 'kindeditor', {
                        options : $.extend({}, $.fn.kindeditor.defaults, $.fn.kindeditor.parseOptions(this), options)
                    });
            }
            create(this);
        });
    };

    $.fn.kindeditor.parseOptions = function (target) {
        return $.extend({}, $.parser.parseOptions(target, []));
    };

    $.fn.kindeditor.methods = {
        editor : function (jq) {
            return $.data(jq[0], 'kindeditor').options.editor;
        }
    };

    $.fn.kindeditor.defaults = {
        resizeType : 1,
        allowPreviewEmoticons : false,
        allowImageUpload : false,
        uploadJson : '${ctx}/wxMessage/uploadImg.yhtml',
        fileManagerJson : '${ctx}/wxMessage/uploadImg.yhtml',
        items : [
'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',  
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',  
'insertunorderedlist', '|', 'emoticons', 'image', 'link','fullscreen','wordpaste','source'],
        afterChange:function(){
            this.sync();//这个是必须的,如果你要覆盖afterChange事件的话,请记得最好把这句加上.
        }
    };
    $.parser.plugins.push("kindeditor");
})(jQuery, KindEditor);



//2   在页面引入  必要的文件   ——kindeditor-4.1.10可以在官方上下载到

<link href="../kindeditor-4.1.10/examples/index.css" rel="stylesheet" />
    <script src="../kindeditor-4.1.10/kindeditor.js"></script>
    <script src="../kindeditor-4.1.10/kindeditor-all.js"></script>
    <script src="../kindeditor-4.1.10/kindeditor-all-min.js"></script>
    <script src="../kindeditor-4.1.10/kindeditor-min.js"></script>
    <script src="../kindeditor-4.1.10/lang/zh_CN.js"></script>
    <script type="text/javascript"
        src="<%=request.getContextPath()%>/js/easyui_kindeditor.js"></script>


// 3   页面上用

<input id="content" name="content" class="easyui-kindeditor" style="width: 90%; height: 140px;visibility: hidden;" options="validType:'length[0,500]'" />


//编辑器

<script type="text/javascript">

var editor;
         KindEditor.ready(function (K) {
             editor = K.create('textarea[name="content"]', {
                 allowFileManager: true,
                 resizeType: 1,
                 allowPreviewEmoticons: false,
                 items: [
                     'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                     'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                     'insertunorderedlist', '|', 'emoticons', 'image', 'link']
             });
         });

</script>

// 4   dataGrid 修改时  赋值  编辑框只能手动赋值    row-选中行的数据    content 编辑器id   填充内容row.content     KindEditor是我们上面重写kindedit是定义的名字


       

function editWxSendMessage(row){
    $("#win").window('open');
    $("#wxsendmessageInfoForm").form('clear');
    $("#wxsendmessageInfoForm").form("load", row);
    KindEditor.html('#content', row.content);
}

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值