dropzone js to link delete url with remove button

后端 未结 3 1524
春和景丽
春和景丽 2021-01-02 14:15

In Dropzonejs i am creating delete button and then appending it to thumbnails, how can i link url which i am geeting from server directly to remove button by using

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 14:45

    you can add delete link .. in Added file event ,you can get URL in Server response and set it in delete link.

     myDropzone.on("addedfile", function (file) {
         var _this = this;
    
         /* Maybe display some more file information on your page */
            var removeButton = Dropzone.createElement("");
    
            removeButton.addEventListener("click", function (e) {
            e.preventDefault();
            e.stopPropagation();
            var server_file = $(file.previewTemplate).children('.server_file').text();
            // Do a post request and pass this path and use server-side language to delete the file
            //          $.post(server_file,{'X-CSRFToken': $cookies.csrftoken}, 'json');
            $http({
                method: 'POSt',
                url: server_file,
                headers: {
                       'X-CSRFToken': $cookies.csrftoken
                }
            });
             _this.removeFile(file);
             });
             file.previewElement.appendChild(removeButton);
     });
    

提交回复
热议问题