Hi i need to upload images with dropzone js to my website. i am using
dropzonejs rails gem it uploads correctly but after upload it doesn't render js.erb file
my js.coffee
Dropzone.options.photoDropzone =
paramName: "paper[paper]"
maxFilesize: 10
addRemoveLinks: true
init: ->
@on "removedfile", (file) ->
if file.xhr
$.ajax
url: "" + ($("#photo-dropzone").attr("action")) + "/" + (JSON.parse(file.xhr.response).id)
type: "DELETE"
my form
= form_for @paper, url: multiple_upload_papers_path(format: :js), remote: true, multipart: true, method: :post, html: {class: :dropzone, id: 'photo-dropzone'} do |p|
= p.hidden_field :id
my controller action
def multiple_upload
@paper = Paper.new
@paper.paper = params[:paper][:paper]
@paper.save
respond_to do |format|
format.js
end
end
and my js.erb file has
console.log('Successfull');
line. It is working correctly it uploads all images but it doesn't render js.erb file after upload. When i check from chrome console it returns js but it doesn't runs it.
just add this to your Dropzone options
success: function (response) {
eval(response.xhr.response);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With