multi-file-inputs now with labels instead of spans
This commit is contained in:
parent
05a0f6b0bf
commit
fe27fab561
@ -24,6 +24,7 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// allows for multiple file uploads with separate inputs
|
||||||
window.utils.reactiveFileUpload = function(input, parent) {
|
window.utils.reactiveFileUpload = function(input, parent) {
|
||||||
var currValidInputCount = 0;
|
var currValidInputCount = 0;
|
||||||
var addMore = false;
|
var addMore = false;
|
||||||
@ -95,9 +96,6 @@
|
|||||||
fileInput.input.addEventListener('blur', function() {
|
fileInput.input.addEventListener('blur', function() {
|
||||||
fileInput.container.classList.remove('pseudo-focus');
|
fileInput.container.classList.remove('pseudo-focus');
|
||||||
});
|
});
|
||||||
fileInput.label.addEventListener('click', function() {
|
|
||||||
fileInput.input.click();
|
|
||||||
});
|
|
||||||
fileInput.remover.addEventListener('click', function() {
|
fileInput.remover.addEventListener('click', function() {
|
||||||
if (fileInput.isValid()) {
|
if (fileInput.isValid()) {
|
||||||
currValidInputCount--;
|
currValidInputCount--;
|
||||||
@ -109,12 +107,14 @@
|
|||||||
// create new wrapped input element with name name
|
// create new wrapped input element with name name
|
||||||
function makeInput(name) {
|
function makeInput(name) {
|
||||||
var cont = document.createElement('div');
|
var cont = document.createElement('div');
|
||||||
var desc = document.createElement('span');
|
var desc = document.createElement('label');
|
||||||
var nextInput = document.createElement('input');
|
var nextInput = document.createElement('input');
|
||||||
var remover = document.createElement('div');
|
var remover = document.createElement('div');
|
||||||
cont.classList.add('file-input__container');
|
cont.classList.add('file-input__container');
|
||||||
desc.classList.add('file-input__label', 'btn');
|
desc.classList.add('file-input__label', 'btn');
|
||||||
|
desc.setAttribute('for', name + '-' + currValidInputCount);
|
||||||
remover.classList.add('file-input__remover');
|
remover.classList.add('file-input__remover');
|
||||||
|
nextInput.setAttribute('id', name + '-' + currValidInputCount);
|
||||||
nextInput.setAttribute('name', name);
|
nextInput.setAttribute('name', name);
|
||||||
nextInput.setAttribute('type', 'file');
|
nextInput.setAttribute('type', 'file');
|
||||||
cont.appendChild(nextInput);
|
cont.appendChild(nextInput);
|
||||||
|
|||||||
Reference in New Issue
Block a user