diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-11-23 20:51:07 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-11-23 20:51:07 +0100 |
commit | 01314169f2820edeb07d4e470151c57a58096bbe (patch) | |
tree | 66d195e2e0ef98c3eccbf17baa59c412da9b5901 /static/input_list.js | |
parent | Further work on breakout and rrule. (diff) | |
download | calp-01314169f2820edeb07d4e470151c57a58096bbe.tar.gz calp-01314169f2820edeb07d4e470151c57a58096bbe.tar.xz |
JS input list propagate addEventListener('input', ...
Diffstat (limited to '')
-rw-r--r-- | static/input_list.js | 15 |
1 files changed, 14 insertions, 1 deletions
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); |