diff --git a/app.js b/app.js index 4943f11..727c2a5 100644 --- a/app.js +++ b/app.js @@ -1321,9 +1321,14 @@ class TeeTracker {
🍃
Keine Tee-Sorten vorhanden
Füge deine erste Tee-Sorte hinzu!
- + `; + // Add event listener for the add button + const addBtn = container.querySelector('.add-first-tea-btn'); + if (addBtn) { + addBtn.addEventListener('click', () => this.openTeaModal()); + } return; } @@ -1369,7 +1374,7 @@ class TeeTracker { } container.innerHTML = teas.map(tea => ` -
+
${tea.name} ${tea.organic ? '🌱' : ''}
${tea.type}
@@ -1380,15 +1385,36 @@ class TeeTracker { ${tea.rating ? this.renderStarRatingStatic(tea.rating) : ''}
`).join(''); + + // Add event listeners to all edit and delete buttons + this.setupTeaCardEventListeners(); + } + + setupTeaCardEventListeners() { + // Edit buttons + document.querySelectorAll('.tea-edit-btn').forEach(btn => { + btn.addEventListener('click', (e) => { + const teaId = e.target.closest('.tea-edit-btn').dataset.teaId; + if (teaId) this.editTea(teaId); + }); + }); + + // Delete buttons + document.querySelectorAll('.tea-delete-btn').forEach(btn => { + btn.addEventListener('click', (e) => { + const teaId = e.target.closest('.tea-delete-btn').dataset.teaId; + if (teaId) this.showDeleteTeaConfirm(teaId); + }); + }); } // ============================================