From 01314169f2820edeb07d4e470151c57a58096bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 23 Nov 2020 20:51:07 +0100 Subject: JS input list propagate addEventListener('input', ... --- static/input_list.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/input_list.js b/static/input_list.js index 3b24b719..9397e6ee 100644 --- a/static/input_list.js +++ b/static/input_list.js @@ -79,6 +79,19 @@ function init_input_list() { } else { lst.get_value = get_get_value(); } + + /* Propagate add event listener downwards */ + lst._addEventListener = lst.addEventListener; + lst.addEventListener = function(type, proc) { + switch (type) { + case 'input': + for (let el of lst.getElementsByTagName('input')) { + el.addEventListener('input', proc); + } + default: + lst._addEventListener(type, proc); + } + }; } } @@ -86,7 +99,7 @@ function init_input_list() { /* different function forms since we want to capture one self */ const get_get_value = (join=',') => function () { - return [...self.querySelectorAll('input')] + return [...this.querySelectorAll('input')] .map(x => x.value) .filter(x => x != '') .join(join); -- cgit v1.2.3