KindEditor

6 篇文章 0 订阅

kindeditor  demo下载:https://download.csdn.net/download/zj420964597/10602616

简单模式kindeditor的使用:

 <!doctype html>
 <html>
 <head>
 <meta charset="utf-8" />
 <title>Simple Examples</title>
 <style>
 form {
 margin: 0;
 }
 textarea {
 display: block;
 }
 </style>
 <link rel="stylesheet" href="../themes/default/default.css" />
 <script charset="utf-8" src="../kindeditor-min.js"></script>
 <script charset="utf-8" src="../lang/zh_CN.js"></script>
 <script>
 
$(function(){
    kedit('textarea[name="content"]');
})

function kedit(s) {
    KindEditor.create(s, {
        resizeType : 1,
        allowPreviewEmoticons : false,
        allowImageUpload : false,
        items : [
            'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
            'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
            'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
        afterCreate : function(){this.sync();},
        afterBlur: function(){this.sync();}
    });
}
//获取编辑器的内容
function getData() {

    var content = $("input[name='content']").val();

         alert(content);

 

}

 </script>
 </head>
 <body>
 <h3>默认模式</h3>
 <form>
 
<textarea name="content" style="width:100%;height:500px;" id="content"></textarea>
<button type="button" class="btn btn-purple btn-round btn-info2" style="float: right; margin-top: 7px;"  onclick="getData()" id="btn">
    <span class="glyphicon"></span> 获取数据
</button>
 </form>
 </body>
 </html>

参考:

https://blog.csdn.net/yangzeqiang/article/details/7916949

https://blog.csdn.net/ameng001/article/details/9187067

http://www.cnblogs.com/mxxim/p/4565613.html

无法进入KindEditor.ready(function(){})的解决办法

最近尝试用 nodeJS + angularJS + express 开发一个简单的文章管理系统项目。

 

发布文章采用的是KindEditor编辑器,一直用这个编辑器感觉还不错,官方文档的使用说明也很详细。然而,今天遇到了个奇葩问题,kindeditor-min.js以及css文件明明已经加载进来了,却进入不了KindEditor.ready(function(K){})里面。用以下代码测试了一下:

1

2

console.log(KindEditor);

console.log(KindEditor.ready());

控制台输出:

1

2

3

function (a,b){function c(a){a[0]||(a=[]);return new D(a)}if(!(a===i||a===null)){if(typeof a==="string"){b&&(b=f(b)[0]);var d=a.length;a.charAt(0)==="@"&&(a=a.substr(1));if(a.length!==d||/<.+>/.test(a)){var d=(b?b.ownerDocument||b:document).createElement("div"),e=[];d.innerHTML='<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />'+a;for(var g=0,h=d.childNodes.length;g<h;g++){var j=d.childNodes[g];

j.id!="__kindeditor_temp_tag__"&&e.push(j)}return c(e)}return c(Ca(a,b))}if(a&&a.constructor===D)return a;a.toArray&&(a=a.toArray());if(Z(a))return c(a);return c(Ja(arguments))}}

undefined

说明KindEditor确实是已经定义了的。  

后来换了一种方式来初始化创建编辑器,突然就好了。。不知道为什么会这样。。

 

原来的代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

KindEditor.ready(function(K) {

    alert("aa");

    window.editor = K.create('textarea[name="content"]', {

        width: '1000px',

        height: '1500px',

        resizeMode: 0,

        allowPreviewEmoticons: false,

        items: [

            'bold''italic''underline',

            '|''justifyleft''justifycenter''justifyright''insertorderedlist',

            'insertunorderedlist''|''emoticons''link']

    });

});

不能弹出“aa”

 

修改后的代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

function kedit(kedit){

    var editor = KindEditor.create(kedit,{

        width: '780px',

        height: '700px',

        resizeMode: 0,

        allowPreviewEmoticons: false,

        items: [

            'bold''italic''underline',

            '|''justifyleft''justifycenter''justifyright''insertorderedlist',

            'insertunorderedlist''|''emoticons''link']

    });

}

 

$(function(){

    kedit('textarea[name="content"]');

})

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值