From d9d761e84913ec8395119230e6dbde7952b7aa4a Mon Sep 17 00:00:00 2001 From: laffra Date: Wed, 3 Jan 2024 23:37:22 +0100 Subject: [PATCH] Fix delete --- ltk/jquery.py | 7 +++++-- ltk/ltk.js | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ltk/jquery.py b/ltk/jquery.py index 1501e70..141e437 100644 --- a/ltk/jquery.py +++ b/ltk/jquery.py @@ -108,10 +108,13 @@ def error(jqXHR, textStatus, errorThrown): def delete(url, handler): - wrapper = proxy(lambda data, *rest: handler(to_py(data))) + @callback + def success(data, *rest): + return handler(to_py(data)) + @callback def error(jqXHR, textStatus, errorThrown): window.console.error("[Network] DELETE ERROR", jqXHR.status, repr(errorThrown), url) - return window.ajax(url, "DELETE", wrapper).fail(proxy(error)) + return window.ltk_delete(url, success, error) def post(url, payload, handler, kind="json"): diff --git a/ltk/ltk.js b/ltk/ltk.js index 41749ff..0bf0e18 100644 --- a/ltk/ltk.js +++ b/ltk/ltk.js @@ -82,4 +82,8 @@ window.ltk_post = (url, payload, success, kind, error) => { $.post(url, payload, success, kind).fail(error) } + + window.ltk_delete = (url, success, error) => { + $.ajax({ url, type: "DELETE", success}).fail(error) + } })() \ No newline at end of file