Addfile fires before hidden input is populated by file-encode plugin
See original GitHub issueHi! Awesome work on this plugin, I love it š
Iām trying to dynamically render the preview image (using the base64 string) outside of the plugin. In order to achieve this, Iām trying to get the base64 string as soon as itās ready so I can update my preview. However, it seems like the FilePond:addfile
event fires before the hidden input is created (let alone ready) and FilePond:processfile
doesnāt seem to fire at allā¦?
How can I access the information in the hidden input when a file is added? Is there a special event for when the file-encode plugin is ready?
My attempt:
FilePond.registerPlugin(FilePondPluginFileEncode);
// original input[type=file]
var input = document.querySelector('input');
// upgrade file input to filepond
FilePond.create(input);
var pond = document.querySelector('.filepond--root');
pond.addEventListener('FilePond:addfile', function() {
// Element doesn't exist yet
console.log('No element: ', pond.querySelector('input[name="filepond"]'));
setTimeout(function () {
// Now the element exists and the value is accessible
console.log('Value: ', pond.querySelector('input[name="filepond"]'));
}, 5000);
});
pond.addEventListener('FilePond:processfile', function(event) {
// Doesn't seem to fire at all?
console.log('Nothing..', event);
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
FilePond Documentation - PQINA
A plugin will fire a FilePond:pluginloaded event on the document when it's ready for use. ... FilePond stores unique id 12345 in a...
Read more >Filepond Receive Undefined Value In Hidden Input - ADocLib
Tells FilePond to store files in hidden file input elements so they can be Set to ... Addfile fires before hidden input is...
Read more >Assign file as value of hidden input - javascript - Stack Overflow
I have tried various ways to implement the method described above ( assign each separate file to the value of an input[type="hidden"] field...
Read more >Overriding/replacing hidden field value - WordPress.org
I am populating the field with the ādefault_cbā parameter which worked perfectly on the first run but of course only fires when there...
Read more >How can I confirm that a hidden form field is populating?
Open the Forms page in Google Chrome from a company IP address. Ā· Open Chrome Web Tools (View > Developer > Developer Tools)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rijkvanzanten For now as a temporary solution, hereās what I did to detect whether the encoding is finished. Iām just polling every 300ms. To a user it should be imperceptible and seems to work. Letās assume youāre submitting a form. The following code should work.
If youāre not using a form to submit, you may need to check for whether the hidden element exists before calling the starting the interval!
@rijkvanzanten @DamSenViet Just published version
1.2.11
of FilePond and1.0.4
of the File Encode plugin. Should fix the issue.