From 40728d2945f25ded7f59004c6c95b8ec19bb5d5b Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 27 Nov 2023 16:27:17 +0100 Subject: [PATCH] adding a return to prevent erros when elements not on the page --- resources/js/archive-template-publications.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/js/archive-template-publications.js b/resources/js/archive-template-publications.js index 2d5d18e..1affbec 100644 --- a/resources/js/archive-template-publications.js +++ b/resources/js/archive-template-publications.js @@ -148,12 +148,15 @@ export default function filterPublicationsInit() { const filterButtons = document.querySelectorAll('.filters-toolbar__action-button'); const loadAllbutton = document.querySelector('.filters-toolbar__action-button--load-all'); + if (!filterButtons) return; filterButtons.forEach((button) => { const publicationType = button.getAttribute('data-publication-type'); button.addEventListener('click', (e) => { filterPublications(publicationType, e); }); }); + + if (!loadAllbutton) return; loadAllbutton.addEventListener('click', (e) => { const publicationType = loadAllbutton.getAttribute('data-publication-type'); filterPublications(publicationType, e);