The :hoplon: ClojureScript Web Framework - http://hoplon.io/

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?

vigilancetech 2018-07-15T18:36:31.000072Z

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?


there's with-dom and with-init! macros in hoplon.core


the former "Evaluates the body after [given] elem has been inserted into the DOM.""


second with-init! "Evaluates the body after Hoplon has completed constructing the page."

vigilancetech 2018-07-15T19:11:53.000024Z

@jjttjj oh yeah, I think I recall seeing that in the demos somewhere


  (fn [] (.log js/console "DOMContentLoaded callback")))
should work also according to https://stackoverflow.com/questions/35706538/equivalent-of-document-readyfunction-in-clojurescript


i think there are differences to each of these


as 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/button :click #(h/set-attributes! my-elem :id (str "new-id-" (rand-int 10))))

vigilancetech 2018-07-15T19:16:12.000009Z

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.




Hey... Anyone know where the haml task went?


fwiw it's possible to use javelin formula directly without macros

vigilancetech 2018-07-15T19:17:55.000014Z

yeah, for some reason my macroexpand isn't working either 😕


ie (cell= (+ a b)) = ((formula +) a b)

vigilancetech 2018-07-15T19:18:12.000047Z

so I'd have to do all that dissecting manually


the latter being no macros

vigilancetech 2018-07-15T19:22:58.000023Z

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


can you post the code here?

vigilancetech 2018-07-15T19:25:14.000030Z

eh, let me see if I can get enough of it together to be informative

vigilancetech 2018-07-15T19:26:14.000043Z

I was trying to duplicate the 2nd working example here: https://clojurians-log.clojureverse.org/hoplon/2017-03-11.html

vigilancetech 2018-07-15T19:28:08.000007Z

(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" )

vigilancetech 2018-07-15T19:29:29.000002Z

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)



vigilancetech 2018-07-15T19:32:08.000021Z

actually I edited that to be a bit more complete

vigilancetech 2018-07-15T19:34:31.000022Z

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

vigilancetech 2018-07-15T19:36:45.000002Z

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



vigilancetech 2018-07-15T19:37:08.000022Z


vigilancetech 2018-07-15T19:37:47.000031Z

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

vigilancetech 2018-07-15T19:48:24.000041Z

sorry, fighting with another error here for a few mins


that seems to be a bit more appropriate of you're looking to handle the click


no worries i was messing with it a bit but have to run out in a min

vigilancetech 2018-07-15T19:48:49.000016Z

oh yeah, I played with that yesterday, but just to do a notify to see when it went off


i vaguely remember running into oddities with checkbox stuff

vigilancetech 2018-07-15T20:03:22.000056Z

it seems like it changes the checkbox checked state BEFORE running the click callback which is somewhat confusing

vigilancetech 2018-07-15T20:05:52.000045Z

preventdefault stops the box from unchecking at all

vigilancetech 2018-07-15T20:15:50.000057Z

: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)

vigilancetech 2018-07-15T23:56:32.000081Z

@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

vigilancetech 2018-07-15T23:57:18.000070Z

yes, I need to bone up on specter a lot. Thanks, I'll check it out.