Skip to content

Instantly share code, notes, and snippets.

@swannodette swannodette/main.cljs Secret
Last active Dec 10, 2015

Embed
What would you like to do?
(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
You can’t perform that action at this time.