This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-24
Channels
- # aws (3)
- # aws-lambda (1)
- # beginners (16)
- # boot (36)
- # cider (3)
- # cljs-dev (90)
- # cljsjs (1)
- # cljsrn (27)
- # clojure (240)
- # clojure-austin (1)
- # clojure-berlin (3)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-germany (12)
- # clojure-russia (19)
- # clojure-spec (20)
- # clojure-uk (56)
- # clojurescript (218)
- # clojurex (1)
- # cursive (21)
- # datomic (10)
- # events (1)
- # hoplon (18)
- # instaparse (19)
- # jobs-discuss (3)
- # lein-figwheel (3)
- # luminus (3)
- # lumo (14)
- # off-topic (4)
- # om (76)
- # onyx (67)
- # protorepl (12)
- # re-frame (54)
- # reagent (35)
- # ring (2)
- # spacemacs (5)
- # specter (2)
- # sql (11)
- # untangled (144)
- # yada (34)
hi All, i think this question has been asked/answered before, but has anyone experienced the situation where when the options of a select have been changed in a loop-tpl and then the selected attribute doesn't respond?
meaning that when the options change, even though the selected attribute is being set correctly (I can inspect it), the correct option is not actually selected on the web page
this seems to work:
(page "index.html")
(defc items [1 2 3 4 5])
(defc selected 1)
(defn- remove-last [_]
(when (seq @items)
(swap! items pop)))
(defn- append [_]
(swap! items
(fn [items]
(if-let [l (last items)]
(conj items (inc l))
[1]))))
(html
(body
(div
(h1 "Select")
(select
(for-tpl [item items]
(option :id (cell= (str item))
:value (cell= (str item))
:selected (cell= (= item selected))
:change (fn [_] (reset! selected item))
(text item))))
(button :click remove-last "Remove last")
(button :click append "Append"))))
was doing some hoplon with @candera today and he showed me some stuff he was doing with document fragments
realized: what if document fragment is what loop-tpl should return?
altho i don't know if a document fragment "disappears" if you append one to an elment
like if you make a doc fragn w/ 3 li kids, and then append the frag to an ol. do the kids become children of the ol?
all questions i could answer for myself in 30 seconds of js console, brb
ok wow. when you appendChild a document fragment to an element, the fragment disappears. its children are spliced in to the new parent
the frag object is still around, but its children are emptied