如何在此代码中重置dropzone? [英] How can I reset the dropzone in this code?

查看:336
本文介绍了如何在此代码中重置dropzone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dropzone.options.imageFile = {
    url: HOST_NAME + USER_NAME + BUILDER_API +'image/',
    method: 'POST',
    // enter code here
    acceptedFiles: '.jpg, .jpeg, .png',
    paramName: "imagefile", // The name that will be used to transfer the file
    maxFilesize: 10, // MB
    //addRemoveLinks: true,
    maxFiles: 2,
    init: function() {
        this.on("success", function(file, response) {
            image_id = response.id;
            IMAGES.push(image_id);
            check_files();
        }),
        this.on("removedfile", function(file, response){
            data = JSON.parse(file.xhr.response);
            alert(data['id']);
        });
    },
};

我需要做什么才能完全重置放置区?

What I have to do to reset the dropzone completely?

推荐答案

不是100%肯定我理解了这个问题,但是我想您希望能够从其原始状态重用dropzone实例。

Not 100% sure I understood the question, but I presume you want to be able to reuse the dropzone instance from its original state.

从技术上讲,您想调用 removeAllFiles(),这将删除所有文件。

Technically you want to call removeAllFiles() and that will remove all the files.

这里是一个示例,向您展示如何使用一个按钮添加删除所有文件:一键式删除所有文件

Here is an example that shows you how to add a remove all files with one button: Remove all files with one button

此外,还有其他人试图这样做您要查找的内容:将dropzone重置为原始状态

Also, there were other people trying to do the same thing that you are looking for: Reset dropzone to Pristine state

这篇关于如何在此代码中重置dropzone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆