From e3a46e0902a6e869fa9d91c3d3104251d6dd21c1 Mon Sep 17 00:00:00 2001 From: pxpm Date: Tue, 17 Sep 2024 11:09:36 +0100 Subject: [PATCH] fix upload multiple selection display --- src/resources/views/crud/fields/upload_multiple.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/resources/views/crud/fields/upload_multiple.blade.php b/src/resources/views/crud/fields/upload_multiple.blade.php index 5e5cf7fa97..9225dbb9f3 100644 --- a/src/resources/views/crud/fields/upload_multiple.blade.php +++ b/src/resources/views/crud/fields/upload_multiple.blade.php @@ -219,6 +219,7 @@ function bpFieldInitUploadMultipleElement(element) { fileInput.change(function() { let selectedFiles = []; + let existingFiles = fileInput.parent().siblings('.existing-file'); Array.from($(this)[0].files).forEach(file => { selectedFiles.push({name: file.name, type: file.type}) @@ -231,11 +232,11 @@ function bpFieldInitUploadMultipleElement(element) { selectedFiles.forEach(file => { files += ''+file.name+' '; }); - + // if existing files is not on the page, create a new div a prepend it to the fileInput if(existingFiles.length === 0) { existingFiles = $('
'); - existingFiles.insertBefore(element.find('input[type=hidden]')); + existingFiles.insertBefore(element.find('input[type=hidden]').first()); existingFiles.html(files); }else { // if existing files is on page show the added files after the uploaded ones