django编辑框实现
Posted qiangayz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django编辑框实现相关的知识,希望对你有一定的参考价值。
一些常用的:
- CKEditor
- UEEditor
- TinyEditor
- KindEditor
下载:
http://kindeditor.net/down.php
使用方法:
<textarea name="comment" id="comment"></textarea> <script> $(function () { initKindEditor(); }); function initKindEditor() { var kind = KindEditor.create( ‘#comment‘, { width: ‘100%‘ , height: ‘300px‘,
uploadJson:‘/uploadimg‘,
extraFileUploadParams: {
‘csrfmiddlewaretoken‘: ‘{{ csrf_token }}‘
} ) } </script>
或者:
var editor; KindEditor.ready(function (K) { editor = K.create(‘textarea[name="comment"]‘, { resizeType: 1, allowPreviewEmoticons: false, allowImageUpload: false, items: [ ‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘, ‘removeformat‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘, ‘insertunorderedlist‘, ‘|‘, ‘emoticons‘, ‘image‘, ‘link‘],
uploadJson:‘/uploadimg‘, #文件上传功能
extraFileUploadParams: {
‘csrfmiddlewaretoken‘: ‘{{ csrf_token }}‘
}); });
后台返回
def uploadimg(request): import json dic = { ‘error‘: 0, ‘url‘: ‘/static/img/4.jpg‘, ‘message‘: ‘错误了...‘ } return HttpResponse(json.dumps(dic))
详细参数
http://kindeditor.net/docs/option.html
内容提交
$(‘#commentsubmit‘).click(function () { console.log(editor.html()) })
相关链接:
https://www.cnblogs.com/wupeiqi/p/6307554.html
以上是关于django编辑框实现的主要内容,如果未能解决你的问题,请参考以下文章