javascript - How to implement confirmation upload in artEditor rich text editor
滿天的星座
滿天的星座 2017-05-19 10:32:54
0
1
536

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);
    }
});
滿天的星座
滿天的星座

reply all(1)
黄舟

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

Click this button to trigger upload

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template