From 8f0ff55383488b9c7158d49ce84bf149f781a250 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 8 Jan 2021 18:28:02 -0800 Subject: [PATCH] Remove deleted bookmark from page without refreshing. --- frontends/etiquette_flask/templates/bookmarks.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/templates/bookmarks.html b/frontends/etiquette_flask/templates/bookmarks.html index cf0a97a..29c8d34 100644 --- a/frontends/etiquette_flask/templates/bookmarks.html +++ b/frontends/etiquette_flask/templates/bookmarks.html @@ -59,8 +59,18 @@ function create_bookmark_form() function delete_bookmark_form(event) { - const id = event.target.closest(".bookmark_card").dataset.id; - api.bookmarks.delete(id, common.refresh_or_alert); + const card = event.target.closest(".bookmark_card"); + const id = card.dataset.id; + function callback(response) + { + if (response.meta.status !== 200) + { + alert(JSON.stringify(response)); + return; + } + card.parentElement.removeChild(card); + } + api.bookmarks.delete(id, callback); } ed_on_open = undefined;