[英]Dropzonejs rails doesn't render js.erb file
Hi i need to upload images with dropzone js to my website. 嗨我需要将带有dropzone js的图像上传到我的网站。 i am using 我在用
dropzonejs rails gem it uploads correctly but after upload it doesn't render js.erb file dropzonejs rails gem正确上传,但上传后它不会呈现js.erb文件
my js.coffee 我的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 和我的js.erb文件有
console.log('Successfull');
line. 线。 It is working correctly it uploads all images but it doesn't render js.erb file after upload. 它正常工作,它上传所有图像,但上传后不会呈现js.erb文件。 When i check from chrome console it returns js but it doesn't runs it. 当我从chrome控制台检查它返回js但它没有运行它。
just add this to your Dropzone options 只需将其添加到Dropzone选项即可
success: function (response) {
eval(response.xhr.response);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.