(編輯器)Jquery-EasyUI集合Kindeditor編輯器

來源:互聯網
上載者:User

標籤:style   java   color   使用   strong   width   

1.在html裡面添加

list.html
list.html(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,                items: [                    ‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘,                    ‘removeformat‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘,                    ‘insertunorderedlist‘, ‘|‘, ‘emoticons‘, ‘image‘, ‘link‘],                afterChange: function () {                    this.sync();                },                afterBlur: function () { this.sync(); }            };            $.parser.plugins.push("kindeditor");        })(jQuery, KindEditor);

 

2.需要同時引用easyui和kindeditor相關樣式和指令碼,然後就可以像使用easyui組件一樣使用kindeditor:

    <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>

調用方法:

<textarea name="easyui_ditor" id="easyui_ditor" class="easyui-kindeditor" style="width: 90%; height: 140px; visibility: hidden;">KindEditor</textarea>

 

3.360瀏覽器不相容,firefox瀏覽器正常,所以賦值方法
KE.html(id, val)
設定編輯器的HTML內容。
參數:
id:String,編輯器的ID
val: String,HTML字串
傳回值:無

頁面只有一個編輯器的話最新版本這樣寫就可以。
KindEditor.html(‘#txtIntroduce‘, data.Introduce);

 

loadFilter: function (data) {                    $.post("../Action/newsList.ashx", { content: $(‘#easyui_ditor‘).val() }, function (data) {                                                var json = eval("(" + data + ")");                        //alert(json.news[0].Content)                        //$(‘#easyui_ditor‘).val(json.news[0].Content);                        KindEditor.html($(‘#easyui_ditor‘), json.news[0].Content);                        //console.info($(‘#easyui_ditor‘).val());                    });

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.