Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created October 17, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alandipert/396ef7759ed320430e6f7a875e58a8f2 to your computer and use it in GitHub Desktop.
Save alandipert/396ef7759ed320430e6f7a875e58a8f2 to your computer and use it in GitHub Desktop.
(page "radio.html")
(defn radio [out-cell vals-labels]
(let [name (gensym "radio")]
(div
(for-tpl [[val label] vals-labels]
(span
(input {:type "radio"
:name name
:change #(reset! out-cell @%)
:value val})
label
(br))))))
(html
(head
(link :href "app.css" :rel "stylesheet" :type "text/css"))
(body
(h1 "Hello, Hoplon!")
(let [sex (cell nil)]
(div
(radio sex
[["male" "Male"]
["female" "Female"]])
(p (text "Sex: ~{sex}"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment