From 9c246fc0ef2b2552630cebe28df3638df9f811bb Mon Sep 17 00:00:00 2001 From: Luc Belliveau Date: Mon, 15 May 2023 12:02:54 -0300 Subject: [PATCH] fix: Handles forms that was on change fixes #38 --- autocomplete/static/autocomplete/js/autocomplete.js | 7 +++++++ autocomplete/templates/autocomplete/component.html | 2 ++ autocomplete/templates/autocomplete/item.html | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/autocomplete/static/autocomplete/js/autocomplete.js b/autocomplete/static/autocomplete/js/autocomplete.js index c33f1ba..9e25fe9 100644 --- a/autocomplete/static/autocomplete/js/autocomplete.js +++ b/autocomplete/static/autocomplete/js/autocomplete.js @@ -1,3 +1,10 @@ +function phac_aspc_autocomplete_trigger_change(container_id) { + setTimeout(() => { + const container = document.getElementById(container_id); + const el = container.querySelector('.textinput'); + el.dispatchEvent(new Event('change', { bubbles: true })); + }, 0) +} function phac_aspc_autocomplete_clear_focus(container, activate_ring) { const hasFocus = container.querySelectorAll('.hasFocus'); diff --git a/autocomplete/templates/autocomplete/component.html b/autocomplete/templates/autocomplete/component.html index 420bf05..e97a856 100644 --- a/autocomplete/templates/autocomplete/component.html +++ b/autocomplete/templates/autocomplete/component.html @@ -7,7 +7,9 @@
{% comment %} Hidden input elements used to maintain the component's state {% endcomment %} {% comment %} and used when submitting forms {% endcomment %} diff --git a/autocomplete/templates/autocomplete/item.html b/autocomplete/templates/autocomplete/item.html index c4a9bc1..6c70e06 100644 --- a/autocomplete/templates/autocomplete/item.html +++ b/autocomplete/templates/autocomplete/item.html @@ -70,4 +70,8 @@ {% endif %} {% endfor %} {% endif %} + + {% endif %} \ No newline at end of file