码迷,mamicode.com
首页 > 其他好文 > 详细

django编辑框实现

时间:2018-06-18 18:13:51      阅读:530      评论:0      收藏:0      [点我收藏+]

标签:ddl   ram   size   lse   for   als   相关   tar   line   

一些常用的:

  • 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编辑框实现

标签:ddl   ram   size   lse   for   als   相关   tar   line   

原文地址:https://www.cnblogs.com/qiangayz/p/9195577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!