Fix jinja variable not defined.

This commit is contained in:
voussoir 2020-09-18 21:28:21 -07:00
parent 3fb198f994
commit 79578823f5

View file

@ -51,7 +51,7 @@
<div id="bookmark_list"> <div id="bookmark_list">
<h2>Bookmarks</h2> <h2>Bookmarks</h2>
{% for bookmark in bookmarks %} {% for bookmark in bookmarks %}
<div class="bookmark_card" data-bookmark-id="{{bookmark.id}}"> <div class="bookmark_card" data-id="{{bookmark.id}}">
<a <a
href="{{bookmark.url}}" href="{{bookmark.url}}"
class="bookmark_title" class="bookmark_title"
@ -77,7 +77,7 @@
<button <button
class="red_button button_with_confirm" class="red_button button_with_confirm"
data-onclick="return delete_bookmark_form();" data-onclick="return delete_bookmark_form(event);"
data-prompt="Delete Bookmark?" data-prompt="Delete Bookmark?"
data-cancel-class="gray_button" data-cancel-class="gray_button"
> >
@ -108,9 +108,10 @@ function create_bookmark_form()
return api.bookmarks.create(url, title, common.refresh); return api.bookmarks.create(url, title, common.refresh);
} }
function delete_bookmark_form() function delete_bookmark_form(event)
{ {
api.bookmarks.delete('{{bookmark.id}}', common.refresh); const id = event.target.closest(".bookmark_card").dataset.id;
api.bookmarks.delete(id, common.refresh);
} }
function on_open(ed, edit_element_map) function on_open(ed, edit_element_map)
@ -158,7 +159,7 @@ function create_editors()
const title_div = card.getElementsByClassName("bookmark_title")[0]; const title_div = card.getElementsByClassName("bookmark_title")[0];
const url_div = card.getElementsByClassName("bookmark_url")[0]; const url_div = card.getElementsByClassName("bookmark_url")[0];
ed = new editor.Editor([title_div, url_div], on_open, on_save, on_cancel); ed = new editor.Editor([title_div, url_div], on_open, on_save, on_cancel);
ed.misc_data["bookmark_id"] = card.dataset.bookmarkId; ed.misc_data["bookmark_id"] = card.dataset.id;
} }
} }