search

Home  >  Q&A  >  body text

javascript - How to implement confirmation upload in artEditor rich text editor

The official demo does not tell when the event will be triggered. There is nothing in the current callback function. Please advise. The following is the official demo, link https://github.com/baixuexiya...

$('#content').artEditor({
    imgTar: '#imageUpload',
    limitSize: 5,   // 兆
    showServer: false,
    uploadUrl: '',
    data: {},
    uploadField: 'image',
    placeholader: '<p>请输入文章正文内容</p>',
    validHtml: ["br"],
    uploadSuccess: function(res) {
            // 这里是处理返回数据业务逻辑的地方
            // `res`为服务器返回`status==200`的`response`
            // 如果这里`return <path>`将会以`<img src='path'>`的形式插入到页面
            // 如果发现`res`不符合业务逻辑
            // 比如后台告诉你这张图片不对劲
            // 麻烦返回 `false`
            // 当然如果`showServer==false`
            // 无所谓咯
        return res.path;
    },
    uploadError: function(res) {
        //这里做上传失败的操作
        //也就是http返回码非200的时候
        console.log(res);
    }
});
滿天的星座滿天的星座2825 days ago523

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-19 10:34:54

    The value of imgTar will generate an imageUpload button with the ID set for you

    Click this button to trigger upload

    reply
    0
  • Cancelreply