From 00864c63e8b0fdcfe837c833748be2b30ef4ae3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 6 Jul 2020 13:30:49 +0200 Subject: [PATCH] show/hide: take selects elements into account --- CHANGELOG.md | 1 + Resources/public/modules/show_hide/show_hide.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9904d3c0f..a66e24049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,4 +144,5 @@ Master Branch - [Export list] improve alignment of last line - [CRUD] Forward query parameters when pushing button "save and new" in "create" page; +- [Show/hide] Take selects input into account; diff --git a/Resources/public/modules/show_hide/show_hide.js b/Resources/public/modules/show_hide/show_hide.js index 5f65e2b18..dd4dfd6db 100644 --- a/Resources/public/modules/show_hide/show_hide.js +++ b/Resources/public/modules/show_hide/show_hide.js @@ -43,7 +43,10 @@ var ShowHide = function(options) { // attach the listener on each input for (let f of froms.values()) { - let inputs = f.querySelectorAll('input'); + let + inputs = f.querySelectorAll('input'), + selects = f.querySelectorAll('select'); + for (let input of inputs.values()) { if (debug) { console.log('attaching event to input', input); @@ -52,6 +55,14 @@ var ShowHide = function(options) { onChange(e); }); } + for (let input of selects.values()) { + if (debug) { + console.log('attaching event to selects', input); + } + input.addEventListener(event_name, function(e) { + onChange(e); + }); + } } // first launch of the show/hide