xxxxxxxxxx
1
<div id="element">
2
</div>
3
1
1
xxxxxxxxxx
1
window.setTimeout(()=> {
2
const template = `
3
<div id="dnd" class="file-upload-wrapper" style="width: 200px; height: 200px;">
4
<input
5
id="avatar-upload"
6
type="file"
7
name="avatar"
8
data-file-upload="file-upload"
9
class="file-upload-input"
10
data-height="200"
11
data-default-msg="Upload your avatar"
12
data-main-error="Ooops, that didn't work"
13
data-disabled-remove-btn="true"
14
data-accepted-extensions="image/*"
15
data-format-error="Bad file format (please choose only image formats)"
16
required
17
/>
18
</div>
19
`
20
const div = document.getElementById('element');
21
div.insertAdjacentHTML('beforeend', template);
22
23
initializeAvatarUploader()
24
}, 2000)
25
26
function initializeAvatarUploader() {
27
const upload = document.getElementById('avatar-upload');
28
new FileUpload(upload);
29
}
30
31
Console errors: 0