Skip to content

Instantly share code, notes, and snippets.

@enyo
Created February 6, 2013 23:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enyo/4726916 to your computer and use it in GitHub Desktop.
Save enyo/4726916 to your computer and use it in GitHub Desktop.
Tweek dropzone to use another container for file previews
Dropzone.myDropzone.options = {
addedfile: function(file) {
file.previewTemplate = $(this.options.previewTemplate);
this.element.find(".previews").append(file.previewTemplate);
file.previewTemplate.find(".filename span").text(file.name);
file.previewTemplate.find(".details").append($("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
}
};
@Maniacsh
Copy link

nice! I don't know how but Google brought me here..

@bcalik
Copy link

bcalik commented Feb 19, 2018

You can just set it like below, so you don't have to fill the content manually.
this.previewsContainer = document.getElementById("another-container");

Edit: this won't work properly because addedFile is called AFTER the file is added. So the next file will be affected, which is not useful.

@normanfernandez
Copy link

Thanks, this really helped me with a dropzone that was driving me nuts.

@eliamartani
Copy link

You can just set it like below, so you don't have to fill the content manually.
this.previewsContainer = document.getElementById("another-container");

Edit: this won't work properly because addedFile is called AFTER the file is added. So the next file will be affected, which is not useful.

Worked for me. Thanks.

@viniciusbig
Copy link

nice! I don't know how but Google brought me here..

The same for me! LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment