I am trying to add an id attribute to every file uploaded to Dropzone.js, so I can sort it later.
This is my code:
Dropzone.options.pictureDropzone = {
paramName: "file",
addRemoveLinks: true,
init: function() {
this.on("success", function(file, response) {
file.serverId = response.id;
$(file.previewTemplate).find('.dz-preview').attr('id', "document-" + file.serverId);
});
}
};
Line
$(file.previewTemplate).find('.dz-preview').attr('id', "document-" + file.serverId);
Must add an id, but it does nothing. Tried this with prop ().
If I select another item, it works fine. for example, this works for .dz-details
$(file.previewTemplate).find('.dz-details').attr('id', "document-" + file.serverId);
But I cannot find a way to add it to the dz-preview element.
The HTML structure looks like this:
<div class="dz-preview dz-processing dz-image-preview dz-success">
<div class="dz-details"> ... </div>
<div class="dz-progress"> ... </div>
<div class="dz-success-mark"> ... </div>
</div>
Thanks for the help:)
source
share