Team name and logo make clickable in the table
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
// Add click event listener to club logos
|
||||
document.querySelectorAll('.club-logo').forEach(logo => {
|
||||
logo.addEventListener('click', (event) => {
|
||||
const clubId = event.target.dataset.team_id;
|
||||
document.querySelectorAll('.club-logo, #club-name').forEach(element => {
|
||||
element.addEventListener('click', (event) => {
|
||||
let clubId;
|
||||
if (element.dataset.teamId) {
|
||||
// If it's a logo, get the club ID from the logo's dataset
|
||||
clubId = element.dataset.teamId;
|
||||
} else {
|
||||
// If it's a team name, get the club ID from the parent row's dataset
|
||||
clubId = event.target.closest('tr').dataset.teamId;
|
||||
}
|
||||
redirectToClubPage(clubId);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Function to redirect to the league page
|
||||
function redirectToClubPage(clubID) {
|
||||
// Append the league name to the URL
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
{{#each league.standings}}
|
||||
<tr>
|
||||
<td>{{table.league_position}}</td>
|
||||
<td><img src="{{table.team_crest}}" alt="{{table.team_name}} Crest" id="table-logo" class="club-logo" data-club-id="{{table.team_id}}"></td>
|
||||
<td>{{table.team_name}}</td>
|
||||
<td><img src="{{table.team_crest}}" alt="{{table.team_name}} Crest" id="club-logo" class="club-logo" data-club-id="{{table.team_id}}"></td>
|
||||
<td><p id="club-name">{{table.team_name}}</p></td>
|
||||
<td>{{games_played}}</td>
|
||||
<td>{{wins}}</td>
|
||||
<td>{{losses}}</td>
|
||||
|
||||
Reference in New Issue
Block a user