Fix Delete button not responding to clicks in gallery
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:
Debian
2026-01-07 21:54:18 +00:00
parent a7cb20fb37
commit 95dd159e89

View File

@@ -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) {
if (!confirm('Are you sure you want to delete this content?')) return;
try {
await api(`/content/${id}`, { method: 'DELETE' });
loadGallery(currentPage);
} catch (error) {
alert(error.message);
}
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/${contentId}`, { method: 'DELETE' });
loadGallery(currentPage);
} catch (error) {
alert(error.message);
}
});
});
}
// Admin