Dropzone.js - Error: Invalid `clickable` option provided

Dropzone.js - Error: Invalid `clickable` option provided

我正在使用 dropbox.js,但出现此错误:错误:提供的 clickable 选项无效 。我已经尝试了关于 clickable 选项的所有可能的解决方案。

  1. clickable: "#add-new",
  2. clickable: '#add-new',
  3. clickable: ['#add-new'],
  4. clickable: ["#add-new"],

我已经更新了我的版本,但我仍然不知道如何修复它。我的 objective 是在每个添加的元素 (previewTemplate) 上附加一个按钮,以便进一步添加新元素。

是否有解决此问题或其他解决方案的解决方法? 谢谢。

var myDropzone = new Dropzone('div#myDropzoneElement2', {
        maxThumbnailFilesize: 2,
        maxFilesize: 2,
        acceptedFiles:'image/*',
        clickable: ["#add-new"],
        thumbnailWidth: 250,
        thumbnailHeight: 125,
        url: dropzoneUrl,
        previewTemplate: "<div class=\"dz-preview dz-file-preview col-sm-12\">\n  <div class=\"row\"><div class=\"col-sm-5 col-md-4\"><div class=\"dz-image\"><img data-dz-thumbnail width=\"100%\"/></div><div class=\"dz-filename\">(<span data-dz-size></span>)</div></div>\n  <div class=\"col-sm-7 col-md-8\"><div class=\"row\"><div class=\"col-sm-12\"><input type=\"text\" id=\"itemtitle\" placeholder=\"Project title\"name=\"itemtitle\" class=\"info-title form-control\"></div>\n <div class=\"top-15 col-sm-12 \"><textarea id=\"itemdescription\" placeholder=\"Describe here the project with essential informations like material and methods applied. Remember the 5Ws and how!\" rows=\"5\" name=\"itemdescription\" class=\"form-control info-description\"></textarea></div></div></div></div>\n   <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n  <div class=\"dz-success-mark\">\n    </div>\n     <div class=\"row\"><div class=\"col-sm-12\"><div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div></div><div class=\"col-sm-6\"><a class=\"dz-remove\" href=\"javascript:undefined;\" data-dz-remove>Remove</a></div><div class=\"col-sm-6\"><button type=\"button\" class=\"dz-update\" id=\"updateinformations\" href=\"javascript:undefined;\" disabled>Update</button></div><div class=\"col-sm-6\"><button type=\"button\" id=\"add-new\">Add New</button></div></div>\n   </div>",
    });

我不确定,但我猜我会说这是因为您传递的 ID 尚未在页面上 - 它在预览模板中。所以 Dropzone 尝试 select 一个不存在的元素。尝试在初始化 Dropzone 之前将 add-new 按钮放在页面上。