Web Dev Solutions

Catalin Mititiuc

From eb3c919f7d5562e0732349f8382534c618bef448 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Fri, 2 Aug 2024 14:44:51 -0700 Subject: Deselect when view changes to another squad --- src/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/index.js b/src/index.js index cc4dd6d..e6a8802 100644 --- a/src/index.js +++ b/src/index.js @@ -266,10 +266,15 @@ document.querySelectorAll('#record-sheet [data-allegiance]').forEach(el => { squadNumbers.forEach(sn => sn.addEventListener('click', function() { - recordContainer.dataset.viewSquadNumber = this.dataset.number; - squadNumbers.forEach(sn => - sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected') - ); + if (!this.classList.contains('selected')) { + recordContainer.dataset.viewSquadNumber = this.dataset.number; + console.log(); + squadNumbers.forEach(sn => + sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected') + ); + + if (el.querySelector('.soldier-record.selected')) Observable.notify('select'); + } }) ); }); -- cgit v1.2.3