编程语言
首页 > 编程语言> > javascript – dropzone js链接删除网址和删除按钮

javascript – dropzone js链接删除网址和删除按钮

作者:互联网

在Dropzonejs我创建删除按钮,然后将其附加到缩略图,我如何通过使用addRemoveLinks直接链接我从服务器geeting的网址删除按钮:true,

//Write function if you need to add some event after files added
      myDropzone.on("addedfile", function(file) {
        console.log('Files Added using ---------->'+$attrs.apiCall);
      var _this=this;
        /* Maybe display some more file information on your page */
       var removeButton = Dropzone.createElement("<button data-dz-remove>-Remove file</button>");
        removeButton.addEventListener("click", function(e) {
        e.preventDefault();
        e.stopPropagation();
        _this.removeFile(file);
        });
        file.previewElement.appendChild(removeButton);
      });

解决方法:

这适用于Dropzone 5.0.0

<script>
    Dropzone.options.dropzoneForm = {
        addRemoveLinks: true,
        dictDefaultMessage: "<strong>Drop files here or click to upload. </strong>",
        init: function() {
            this.on("complete", function(file) {
                $(".dz-remove").html("<div><span class='fa fa-trash text-danger' style='font-size: 1.5em'></span></div>");
            });
        }
    };
</script>

标签:javascript,jquery,dropzone-js
来源: https://codeday.me/bug/20191006/1858271.html