-
-
Save swannodette/65ee1280c5c725ae9214 to your computer and use it in GitHub Desktop.
This file contains 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
(ns store.admin.forms | |
(:require [domina :as d] | |
[domina.events :as e] | |
[store.helpers :as sh])) | |
(defn add-model-name [] | |
(e/listen! (d/by-id "add-model") :click | |
(fn [evt] | |
(e/prevent-default evt) | |
(sh/ajax-response (d/attr (d/by-id "add-model") :href) | |
(fn [content] | |
(sh/create-dialog | |
{:title "Create Model" | |
:body content})))))) | |
(defn ^:export main [] | |
(add-model-name)) | |
;;Helper functions called from store.admin.forms | |
(ns store.helpers | |
(:require [goog.ui.Dialog :as dlg] | |
[simple-xhr :as sxhr] | |
[goog.Uri :as uri])) | |
(defn create-dialog [{dtitle :title dbody :body }] | |
(doto (new goog.ui.Dialog) | |
(.setContent dbody) | |
(.setTitle dtitle) | |
(.setVisible true) | |
(.setModal true))) | |
(defn ajax-response [url callback] | |
(sxhr/request | |
:url (goog.Uri. url) | |
:method "GET" | |
:complete | |
(fn [xhrio] | |
(let [content (.getResponseXml xhrio)] | |
(callback content))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment