KindEditor

首先导入

<script src="/static/plugins/kindeditor/kindeditor-all.js"></script>


KindEditor模板套用

var editor;
KindEditor.ready(function (K){
editor=K.create(
'#id_contentss',//定位富文本框
{
resizeType: 1,
allowPreviewEmoticons: false,
allowImageUpload: true,
items: [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
afterCreate : function() { this.sync(); },//将KindEditor里面写的内容同步到textarea中,这样后台就能获取到
afterBlur: function(){this.sync();}//如果用form提交的话,就写上标红的部分



}
)

});

KindEditor传图片预览
views部分

def laocunzhang(request):
ret = {'status': '','msg': ""}
print(request.POST)
print(request.FILES)
dic = {
'error': 0,
'url': '/static/imgs/4.jpg',
'message': '错误了...'
}

return JsonResponse(dic)

 

 

template部分

 

 

<script charset="utf-8" src="/static/plugins/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/static/plugins/kindeditor/lang/zh_CN.js"></script>
<script>
var editor;
KindEditor.ready(function (K) {
editor = K.create('textarea[name="content"]', {
resizeType: 1,
allowPreviewEmoticons: false,
allowImageUpload: false,
items: [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],

url:'/laocunzhang'
});
});
</script>

在前端获取KindEditor中的值通过editor.html()

 






转载于:https://www.cnblogs.com/wangtc/p/10728336.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值