【发布时间】:2015-01-10 09:20:20
【问题描述】:
我在我的 ruby on rails 项目中使用 Dropzone.js,我需要将 html 正文作为可放置的,因此我可以将文件拖放到页面上的任何位置,我在 JIRA 上看到了这个,同时创建了新的故事,确实做到了我想 。以下是我的代码
in js file I did the following
------------------------------------------------
Dropzone.options.documentDropzone = {
autoProcessQueue: false,
init: function() {
myDropzone = this;
var submitButton = document.querySelector("#buttondropzone")
submitButton.addEventListener("click", function() {
myDropzone.hiddenFileInput.click();
});
this.on("addedfile", function(file) {
$("#smallModal").modal('show');
});
this.on("sending", function(file, xhr, formData){
if ($("#docName").val() == ""){
this.removeAllFiles(true);
}else {
//formData.append('name', $("#docName").val());
}
});
this.on("success",function(file,data){
this.removeAllFiles(true);
});
}
my form looks like the following
---------------------------------------
= simple_form_for @object , url: someurl , :html => {id: 'document-dropzone', class: 'dropzone', multipart: true} do |f|
= f.input :document ,:as => :file , :label => false , :input_html => {class: "hide"}
我已经检查了以下链接 Make the whole body a dropzone ,但他们直接将 dropzone 配置为 document.body 但在我的情况下,我为表单配置了 dropzone 并在 js 文件中使用了选项。
谁能帮助我将整个页面设置为可放置
提前致谢
【问题讨论】:
标签: jquery ruby-on-rails-4 dropzone.js