From 0d76691705dbbaa8b3972e09ed8df1e590b38da5 Mon Sep 17 00:00:00 2001 From: Jan C Date: Mon, 15 Feb 2016 09:48:44 +0100 Subject: =?UTF-8?q?grils=20k=C3=B6nnen=20nun=20gel=C3=B6scht=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/assets_src/js/lib/ajax.js b/assets_src/js/lib/ajax.js index 048f516..b189a92 100644 --- a/assets_src/js/lib/ajax.js +++ b/assets_src/js/lib/ajax.js @@ -58,3 +58,6 @@ export async function get(url, options) { export async function post(url, body, options) { return request('POST', url, body, options); } +export async function del(url, body, options) { + return request('DELETE', url, body, options); +} diff --git a/assets_src/js/list.js b/assets_src/js/list.js index be7f007..7a4f69e 100644 --- a/assets_src/js/list.js +++ b/assets_src/js/list.js @@ -68,8 +68,19 @@ async function listButtonHandler(e) { } break; case 'gril-delete': - //TODO: backend + let liFilter = x => x.tagName && x.tagName.toLowerCase() === 'li'; + let item = dom.closest(e.target, liFilter); + try { + await ajax.del( + `${window.location}/order`, + `gril=${item.id}`, + { headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } }); item.parentNode.removeChild(item); + } catch(e) { + alert(e.message); + } break; } } -- cgit v0.10.1