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


clickable: "#add-new",
clickable: '#add-new',
clickable: ['#add-new'],
clickable: ["#add-new"],


我已经更新了版本,但仍然不知道如何解决。我的目标是在每个添加的元素(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试图选择一个不存在的元素。在初始化Dropzone之前,尝试将add-new按钮放在页面上。

关于javascript - Dropzone.js-错误:提供了无效的“clickable”选项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42203205/

10-12 15:40