This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-15
Channels
- # beginners (16)
- # cljs-dev (12)
- # clojure (9)
- # clojure-berlin (5)
- # clojure-russia (16)
- # clojure-uk (26)
- # clojurescript (48)
- # community-development (2)
- # cursive (1)
- # data-science (10)
- # datomic (7)
- # emacs (27)
- # figwheel-main (31)
- # fulcro (6)
- # hoplon (47)
- # immutant (1)
- # jobs (1)
- # jobs-discuss (33)
- # off-topic (3)
- # onyx (34)
- # protorepl (5)
- # re-frame (26)
- # reagent (1)
- # reitit (1)
- # shadow-cljs (80)
- # spacemacs (44)
- # specter (4)
- # testing (1)
- # tools-deps (4)
Hey... So I'm getting this strange error about > template already refers to: #'boot.core/template in namespace: adzerk.boot-reload Anyone know what's going on?
how do I get the document.ready or window.onload callback to work (to run my code after the web page has loaded)? Either that or how do I elegantly get the address of a DOM element so I can manipulate it directly? I'm having a problem with some checkboxes not javelin updating based on changed data being extracted with specter after the checkbox has been manually manipulated (strangely until I either restart the boot process and browser, or make a change to the hl source file and recompile then boot's reload puts everything back right; the browser reload button -- even WITH shift -- doesn't help). I could .getElementById every time something changes but it seems somewhat wasteful.
@vigilancetech can you post the code example that's not working?
second with-init!
"Evaluates the body after Hoplon has completed constructing the page."
@jjttjj oh yeah, I think I recall seeing that in the demos somewhere
(.addEventListener
js/window
"DOMContentLoaded"
(fn [] (.log js/console "DOMContentLoaded callback")))
should work also according to https://stackoverflow.com/questions/35706538/equivalent-of-document-readyfunction-in-clojurescriptas for getting a dom element to manipulate it, usually that's the wrong way to think in hoplon. you don't need to get an elem by address because you usually work with the elements directly
(def my-elem (h/div "hello world"))
(h/html
(h/head)
(h/body
(h/button :click #(h/set-attributes! my-elem :id (str "new-id-" (rand-int 10))))
my-elem))
yes, I realize the situation is effed up, but its something to do with specter and javelin macros not playing well together but I'm on a deadline right now.
yeah, for some reason my macroexpand isn't working either 😕
so I'd have to do all that dissecting manually
yeah, its kind of a complicated formula. I might be able to load it up in a clojure, rather than clojurescript, repl and macroexpand it to see what it produces. The clojurescript one just gives me back what I put in
eh, let me see if I can get enough of it together to be informative
I was trying to duplicate the 2nd working example here: https://clojurians-log.clojureverse.org/hoplon/2017-03-11.html
(defn n-device-records [type] [:lights sp/ALL #(= (:type %) type)])
(defn effects [d type] (sp/select [(n-device-records type) :effect] d))
(defn fan-effects [d] (effects d :fan))
(defc= f-e (not (every? #(= "none" %) (fan-effects data))))
then in (window...
(input :id "FANS" :value "FANS" :type "checkbox"
:checked (cell= f-e)
:click #(do (if (checked? "FANS") (checkbox-checked :fan)
(checkbox-unchecked :fan))
true) "FANS" )
The checkbox is supposed to automatically track the state of the effect, but when it gets checked off manually (which disables the device group) but then one device in the group gets enabled, the checkbox no longer tracks (e.g. the javelin cell doesn't appear to be running)
actually I edited that to be a bit more complete
the reference "data" is getting updated in real time by another part of the program
this is kinda a long shot but what about putting a (.preventDefault %) in the :click handler just above the true
return value
like the thing the do does just before returning true?
my initial thought is that maybe the default dom action is to set the value of the checkbox to "true" on a click in place of the cell that was there
I can go in with JS interop and force the checkbox back on and it works, but not otherwise except for a total restart or a boot reload after an edit/compile
another quick "throw stuff at the wall" thing to try is maybe try :change
instead of :click
for the handler
sorry, fighting with another error here for a few mins
oh yeah, I played with that yesterday, but just to do a notify to see when it went off
it seems like it changes the checkbox checked state BEFORE running the click callback which is somewhat confusing
preventdefault stops the box from unchecking at all
:change works with .preventDefault but the javelin problem remains
@vigilancetech f-e
is already a formula cell. Do you need to wrap it in another for :checked
?
Also maybe define the specter path fn n-device-records using (sp/path)
@chromalchemy well, I was following the 2nd working example in that page I linked. Its so brittle I haven't tried more possibilities. Obviously that wasn't a complete solution cuz I tried to be pretty true to its form
yes, I need to bone up on specter a lot. Thanks, I'll check it out.