Club ID is now correctly passed in to create club pages
This commit is contained in:
@@ -1,24 +1,17 @@
|
|||||||
// Add click event listener to club logos
|
// Add click event listener to club logos
|
||||||
document.querySelectorAll('.club-logo, #club-name').forEach(element => {
|
document.querySelectorAll('.club-logo').forEach(element => {
|
||||||
element.addEventListener('click', (event) => {
|
element.addEventListener('click', (event) => {
|
||||||
let clubId;
|
// Get the club ID from the clicked club logo's clubID attribute
|
||||||
if (element.dataset.teamId) {
|
const clubId = element.getAttribute('clubID');
|
||||||
// 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);
|
redirectToClubPage(clubId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Function to redirect to the club page
|
||||||
// Function to redirect to the league page
|
|
||||||
function redirectToClubPage(clubID) {
|
function redirectToClubPage(clubID) {
|
||||||
// Append the league name to the URL
|
// Append the club ID to the URL
|
||||||
var url = "/club/" + clubID;
|
var url = "/club/" + clubID;
|
||||||
|
|
||||||
// Redirect to the league page
|
// Redirect to the club page
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
{{#each league.standings}}
|
{{#each league.standings}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{table.league_position}}</td>
|
<td>{{table.league_position}}</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><img src="{{table.team_crest}}" alt="{{table.team_name}} Crest" id="club-logo" class="club-logo" clubID="{{table.team_id}}"></td>
|
||||||
<td><p id="club-name">{{table.team_name}}</p></td>
|
<td><p id="club-name">{{table.team_name}}</p></td>
|
||||||
<td>{{games_played}}</td>
|
<td>{{games_played}}</td>
|
||||||
<td>{{wins}}</td>
|
<td>{{wins}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user