Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropzonejs rails doesn't render js.erb file

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.

chrome console result

like image 521
htkaya Avatar asked Feb 18 '15 09:02

htkaya


1 Answers

just add this to your Dropzone options

   success: function (response) {
                eval(response.xhr.response);
            }
like image 75
Aditya Shanker Tagirisa Avatar answered Sep 17 '22 23:09

Aditya Shanker Tagirisa