Last active
December 20, 2019 22:14
-
-
Save aarkerio/2a672154842c68063e713ccbb6b67c87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Clojure hiccup file | |
[:button {:class "btn btn-success" :onClick (str "zentaur.core.deletetest("id")")} "Löschen"] | |
;; file: src/cljs/zentaur/core.cljs | |
(ns zentaur.core | |
(:require [ajax.core :refer [GET POST DELETE]])) | |
(defn delete-test [test-id] | |
(let [csrf-field (.-value (gdom/getElement "__anti-forgery-token"))] | |
(DELETE "/admin/tests/deletetest" | |
{:params {:test-id test-id} | |
:headers {"x-csrf-token" csrf-field} | |
:handler (fn [] (set! js/window.location.href "/admin/tests")) | |
:error-handler error-handler}))) | |
(defn ^:export deletetest [test-id] | |
(when (js/confirm "Delete test?") | |
(delete-test test-id))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment