From ca6c80c08dbc98a2cb7f2e0f95070d700c098993 Mon Sep 17 00:00:00 2001 From: Alexis Allemann <47788288+alexis-allemann@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:16:56 +0200 Subject: [PATCH] T1643 - Letter writing child selection (#34) * Current child id injected in the links using a querySelector * Formatting fix * Formatting fix --- my_compassion/static/src/js/my_children.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/my_compassion/static/src/js/my_children.js b/my_compassion/static/src/js/my_children.js index d8237d9..49a0a97 100644 --- a/my_compassion/static/src/js/my_children.js +++ b/my_compassion/static/src/js/my_children.js @@ -3,6 +3,15 @@ const child_images = document.getElementsByClassName("child-image"); const child_name = document.getElementsByClassName("child-name"); const child_local_id = document.getElementsByClassName("child-local_id"); +// Change the href of the links to include the child_id +const current_child_id = new URLSearchParams(window.location.search).get( + "child_id" +); +selector = document.querySelector('a[href="/my/letter"]'); +selector.href = selector.href + "?child_id=" + current_child_id; +selector = document.querySelector('a[href="/my/children"]'); +selector.href = selector.href + "?child_id=" + current_child_id; + function selectChild(selected_child_id, reload) { // Change url to display selected child const search_params = new URLSearchParams(window.location.search);