我在dropzonejs中预览图片时遇到问题。当我重新加载我的页面时,服务器上的所有照片都会加载到此dropzone。有些照片无法完全加载。我该如何修复这个错误。
还有我的js代码。
Dropzone.options.mydropzone = {
paramName: "upload[image]",
maxFilesize: 2,
addRemoveLinks: true,
thumbnailWidth: 300,
thumbnailHeight: 300,
success: function(file, response) {
$(file.previewElement).find('.dz-remove').attr('id', response.uploadId);
$(file.previewElement).addClass('dz-success');
},
removedfile: function(file) {
var id = $(file.previewTemplate).find('.dz-remove').attr('id');
$.ajax ({
type: 'DELETE',
url: "/uploads/" + id,
success: function(data) {
console.log(data.message);
}
});
var previewElement;
return (previewElement = file.previewElement) != null ? (previewElement.parentNode.removeChild(file.previewElement)) : (void 0);
},
init: function() {
var me = this;
$.get("<%= Rails.application.routes.url_helpers.list_uploads_path %>",
function(data){
$.each(data.images, function(key, value){
if(data.images != undefined && data.images.length > 0) {
me.emit("addedfile", value);
me.emit("thumbnail", value, value.src);
me.emit("complete", value);
$(value._removeLink).attr("id", value.id);
}
});
});
} };