From c5c98e62a0ee98aa5d814b9afedeb170aa5d90e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 18 Jan 2023 13:13:22 +0100 Subject: [PATCH] montpellier: add toggling event to roadworks asynchronously loaded (#73552) --- static/montpellier-ville/extra.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/montpellier-ville/extra.js b/static/montpellier-ville/extra.js index cec089a5..a958d8b8 100644 --- a/static/montpellier-ville/extra.js +++ b/static/montpellier-ville/extra.js @@ -13,5 +13,10 @@ $(function() { } }); }); - $('.chantier').on('click', function() { $(this).toggleClass('shown'); }); + if ($('.page-template-roadworks-map').length) { + $(document).on('combo:cell-loaded combo:roadworks-loaded', function(ev, elem) { + $('.chantier').off('click').on('click', function() { $(this).toggleClass('shown'); }); + }); + $(document).trigger('combo:roadworks-loaded'); + } });