From 618a768f9acb5f144aea6f0a6854956f346022b0 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 19 Aug 2023 02:48:40 +0100 Subject: [PATCH] Fix not being able to remove packages added by query field --- app/public/static/collection_editor.js | 9 ++++++--- app/templates/collections/create_edit.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/public/static/collection_editor.js b/app/public/static/collection_editor.js index ad1303b7..c5e66379 100644 --- a/app/public/static/collection_editor.js +++ b/app/public/static/collection_editor.js @@ -84,9 +84,12 @@ function addPackage(pkg) { `; - const newElement = temp.children[0]; - document.getElementById("package_list").appendChild(newElement); - newElement.scrollIntoView(); + const card = temp.children[0]; + document.getElementById("package_list").appendChild(card); + card.scrollIntoView(); + + const button = card.querySelector(".btn-danger"); + button.addEventListener("click", () => removePackage(card)); } diff --git a/app/templates/collections/create_edit.html b/app/templates/collections/create_edit.html index 355f94eb..4b43e56a 100644 --- a/app/templates/collections/create_edit.html +++ b/app/templates/collections/create_edit.html @@ -9,7 +9,7 @@ {% endblock %} {% block scriptextra %} - + {% endblock %} {% block content %}