diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/views/dashboard.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/public/views/dashboard.html b/public/views/dashboard.html index 03dd653..65db495 100644 --- a/public/views/dashboard.html +++ b/public/views/dashboard.html @@ -91,6 +91,17 @@ const deleteButton = document.createElement('a'); deleteButton.className = 'btn btn-danger'; deleteButton.innerHTML = 'Delete Post'; + deleteButton.addEventListener('click', () => { + if (confirm('Are you sure you want to delete this post?')) { + $.ajax({ + url: `/api/blog/delete/${post.slug}`, + type: 'DELETE', + success: () => { + window.location.reload(); + } + }); + } + }); const editButtonContainer = document.createElement('div'); editButtonContainer.className = 'btn-group'; editButtonContainer.appendChild(editButton); |
