【发布时间】:2015-02-12 11:28:39
【问题描述】:
我已关注this FAQ 和其他各种关于在 dropzone 中显示已在服务器上的文件的 SO 问题。
我无法以“已完成”状态显示文件,即隐藏开始/取消上传按钮,显示删除按钮。
根据常见问题解答,这行应该处理它:
// Make sure that there is no progress bar, etc...
myDropzone.emit("complete", mockFile);
很遗憾,这些文件仍然显示,就好像它们刚刚添加到上传队列中一样。
谁能指出我正确的方向?
var myDropzone = new Dropzone(document.body, { // Make the whole body a dropzone
url: "/upload/", // Set the url
thumbnailWidth: 80,
thumbnailHeight: 80,
parallelUploads: 20,
previewTemplate: previewTemplate,
autoQueue: false, // Make sure the files aren't queued until manually added
previewsContainer: "#previews", // Define the container to display the previews
clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
init: function () {
var myDropzone = this;
var thumbnailUrls = [
{name: 'myimage1.jpg', size: 312, type: 'image/jpeg', url: 'skdfjlk'},
{name: 'another2.png', size: 0928, type: 'image/png', url: 'aeserre'}
];
//Populate any existing thumbnails
if (thumbnailUrls) {
for (var i = 0; i < thumbnailUrls.length; i++) {
var mockFile = {
name: thumbnailUrls[i].name,
size: thumbnailUrls[i].size,
type: thumbnailUrls[i].type,
status: Dropzone.ADDED,
url: thumbnailUrls[i].url
};
// Call the default addedfile event handler
myDropzone.emit("addedfile", mockFile);
// And optionally show the thumbnail of the file:
myDropzone.emit("thumbnail", mockFile, thumbnailUrls[i]);
myDropzone.emit("complete", mockFile);
myDropzone.files.push(mockFile);
}
}
}
});
【问题讨论】:
-
您使用的是哪个版本的 dropzone? v4.0?
-
我上周下载了它。所以我相信 4.0.0。
-
你能详细说明什么仍然可见并且不应该存在吗?屏幕截图将是理想的。
-
@enyo 我在我的问题中添加了一个屏幕截图。基本上显示开始和取消上传按钮,我希望看到删除按钮
-
嗯,好的,所以你使用了引导主题示例!