diff --git a/site/assets/js/tac.js b/site/assets/js/tac.js index bd9677b59c..b4bde25e23 100644 --- a/site/assets/js/tac.js +++ b/site/assets/js/tac.js @@ -51,7 +51,7 @@ '#googletagmanagerLine .tarteaucitronAsk' ) var choiceEvent = - 'tarteaucitron.userInterface.respond(document.getElementById("googletagmanagerAllowed"),document.getElementById("googletagmanagerAllowed").checked);' + 'tarteaucitron.userInterface.respond(document.getElementById(\'googletagmanagerAllowed\'),document.getElementById(\'googletagmanagerAllowed\').checked);' var toggle = document .createRange() .createContextualFragment( @@ -61,7 +61,13 @@ ) ask.innerHTML = '' ask.append(toggle) + }, + { once: true } + ) + window.addEventListener( + 'tac.open_panel', + function () { var allowConsentButton = document.querySelector('#tarteaucitronAllAllowed') var denyConsentButton = document.querySelector('#tarteaucitronAllDenied') var checkboxes = document.querySelectorAll('.form-check-input') @@ -83,6 +89,7 @@ }, { once: true } ) + })() if (typeof tarteaucitron !== 'undefined') {