This commit is contained in:
jheaps
2025-10-09 11:09:31 -06:00
parent 5ce1f88372
commit f4c88f83df
5 changed files with 38 additions and 16 deletions
+6 -3
View File
@@ -89,7 +89,7 @@ function createGalleryItem(media) {
const form = document.createElement('form');
form.method = 'post';
form.action = '/?handler=Delete';
form.action = '?handler=Delete'; // Relative to current page
form.style.display = 'inline';
// Add anti-forgery token
@@ -101,7 +101,7 @@ function createGalleryItem(media) {
const hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = 'mediaId';
hiddenInput.name = 'MediaId'; // Match C# property name exactly
hiddenInput.value = media.id;
form.appendChild(hiddenInput);
@@ -110,7 +110,10 @@ function createGalleryItem(media) {
deleteBtn.className = 'btn-delete';
deleteBtn.textContent = 'Delete';
deleteBtn.onclick = function(e) {
return confirm('Are you sure you want to delete this image?');
if (!confirm('Are you sure you want to delete this image?')) {
e.preventDefault();
return false;
}
};
form.appendChild(deleteBtn);