2017-02-13 29 views
0

我使用的是dropbox.js,我得到這個錯誤:錯誤:無效clickable提供的選項。我嘗試了所有關於clickable選項的解決方案。Dropzone.js - 錯誤:提供無效的`clickable`選項

  1. clickable: "#add-new",
  2. clickable: '#add-new',
  3. clickable: ['#add-new'],
  4. 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>", 
    }); 

回答

1

我不知道某些,但在猜我會說這是因爲你通過ID是不是在頁面上還沒有 - 這是在預覽模板。所以Dropzone嘗試選擇一個不存在的元素。嘗試在Dropzone初始化之前在頁面上放置add-new按鈕。

+0

愚蠢的我,感謝指出! – XiLab

相關問題