Use event delegation for suggestion clicks + add debug log
- Single onclick handler on list container - Uses closest() to find clicked item - Added console.log for debugging
This commit is contained in:
+7
-5
@@ -644,16 +644,18 @@
|
|||||||
`;
|
`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
// Add click listeners to suggestion items
|
// Add click listeners to suggestion items using event delegation
|
||||||
list.querySelectorAll('.suggestion-item').forEach(item => {
|
list.onclick = function(e) {
|
||||||
item.addEventListener('click', () => {
|
const item = e.target.closest('.suggestion-item');
|
||||||
|
if (item) {
|
||||||
const operatorId = item.dataset.operatorId;
|
const operatorId = item.dataset.operatorId;
|
||||||
|
console.log('Clicked suggestion:', operatorId);
|
||||||
if (!selectedTeam.includes(operatorId) && selectedTeam.length < 4) {
|
if (!selectedTeam.includes(operatorId) && selectedTeam.length < 4) {
|
||||||
selectedTeam.push(operatorId);
|
selectedTeam.push(operatorId);
|
||||||
updateTeamUI();
|
updateTeamUI();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user