Re: [Clojurescript] .getElementById returns NULL
Thanks Francis, that did it. Rookie mistake, that. I wonder if there's ever enough page content to make it worth just delaying the DOM hooks. On Sunday, January 3, 2016 at 7:49:39 PM UTC-8, Francis Avila wrote: > > Your problem is unrelated to clojurescript. > > Your script runs before the body is loaded, so the test-content element > doesn't exist yet. > > Either load your script at the end of the body, or wrap your code in a > document.onload event handler. > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Clojurescript] .getElementById returns NULL
Sorry if this is something trivial. I tried to do some due diligence googling with no luck. The function getElementById seems to be returning null where it shouldn't. I'm currently using lein-cljsbuild 1.1.2 clojure 1.7.0 clojurescript 1.7.170 and compiling with optimizations: :none Here's my HTML: Test text Here's my Clojurescript: (ns gol-cljs.core) (.log js/console (. js/document getElementById "test-content")) This prints "null" to Chrome's browser console. Attempting any operations on (. js/document getElementById "test-content")) gives errors about trying to do things with "null". Is there some requirement I'm missing for accessing the dom? Best, Nathan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Clojurescript] .getElementById returns NULL
On Sun, Jan 3, 2016 at 8:04 PM, Nathan Smutzwrote: > > (.log js/console (. js/document getElementById "test-content")) > > I suspect you need something more like this: (.log js/console (.getElementById js/document "test-content")) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Clojurescript] .getElementById returns NULL
Your problem is unrelated to clojurescript. Your script runs before the body is loaded, so the test-content element doesn't exist yet. Either load your script at the end of the body, or wrap your code in a document.onload event handler. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.