How do I set up multiple FilePond file input elements on the same page?

此生再无相见时 提交于 2021-02-08 11:14:08

问题


Whenever I try to create multiple Filepond inputs on the same webpage, only the first input get styled and works perfectly as the example on the FilePond website the others doesn't work. Please help as I have tried my best and still not getting it. ScreenShot of what I mean


回答1:


It looks like the fields in the screenshot are not initialised, you need to target each field you want to turn into a FilePond instance.

See example code here for a single instance. https://pqina.nl/filepond/docs/patterns/api/filepond-object/#creating-a-filepond-instance

For multiple instances it should be something like:

<input type="file" class="filepond">
<input type="file" class="filepond">
<input type="file" class="filepond">

<script>
// get a collection of elements with class filepond
const inputElements = document.querySelectorAll('input.filepond');

// loop over input elements
Array.from(inputElements).forEach(inputElement => {

  // create a FilePond instance at the input element location
  FilePond.create(inputElement);

})
</script>


来源:https://stackoverflow.com/questions/62622588/how-do-i-set-up-multiple-filepond-file-input-elements-on-the-same-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!