Jeboy
Jeboy

Reputation: 228

How to use addedfile event listener of dropzone.js to add an element to the preview?

I'd like to append a radio button for each preview element like a default or primary photo function. How can I do it without touching the dropzone.js code and how to post the dropzone form even if there's no newly uploaded file, e.g. the dropzone form is showing files from server and I only want to tick a default picture.

Upvotes: 3

Views: 10187

Answers (1)

Jeboy
Jeboy

Reputation: 228

    myDropzone.on("addedfile", function(file) {
      // Add default option box for each preview.
      var defaultRadioButton = Dropzone.createElement('<div class="default_pic_container"><input type="radio" name="default_pic" value="'+file.name+'" /> Default</div>');
      file.previewElement.appendChild(defaultRadioButton);
    });

Upvotes: 5

Related Questions