Fix Delete button not responding to clicks in gallery
All checks were successful
Build and Push Frontend Docker Image / build (push) Successful in 29s
All checks were successful
Build and Push Frontend Docker Image / build (push) Successful in 29s
Same issue as View Progress button - replace inline onclick handler with proper addEventListener to fix silent failures from async promise rejections. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -428,23 +428,25 @@ function renderGallery(container, items) {
|
||||
<span>${formatDate(item.createdAt)}</span>
|
||||
<div class="gallery-item-actions">
|
||||
${item.status === 'completed' ? `<a href="/api/content/${item.id}/download" class="btn btn-sm btn-secondary">Download</a>` : ''}
|
||||
<button class="btn btn-sm btn-danger" onclick="deleteContent(${item.id})">Delete</button>
|
||||
<button class="btn btn-sm btn-danger delete-content-btn" data-content-id="${item.id}">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
async function deleteContent(id) {
|
||||
container.querySelectorAll('.delete-content-btn').forEach(btn => {
|
||||
btn.addEventListener('click', async function() {
|
||||
const contentId = parseInt(this.dataset.contentId, 10);
|
||||
if (!confirm('Are you sure you want to delete this content?')) return;
|
||||
|
||||
try {
|
||||
await api(`/content/${id}`, { method: 'DELETE' });
|
||||
await api(`/content/${contentId}`, { method: 'DELETE' });
|
||||
loadGallery(currentPage);
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Admin
|
||||
|
||||
Reference in New Issue
Block a user