small medium large xlarge

01 Aug 2017, 21:24
Justin Calcagni (17 posts)

This was noted in the errata section, but it isn’t clear to me how to resolve it

I added the modal function to the components/common.cljs file. Below is the cljs/picture_gallery/core.cljs file

I added the require section and the page function but that will never be called based on the init and mount-components. Should I remove them? (just for fun I did but it had no effect) -

(ns picture-gallery.core (:require [picture-gallery.components.common :as c])

(defn page [] [:div ;;modal test [c/modal “I’m a modal” [:p “This is the body”] “this is the footer”] [(pages (session/get :page))]])

(defn mount-components [] (let [content (js/document.getElementById “app”)] (while (.hasChildNodes content) (.removeChild content (.-lastChild content))) (.appendChild content (js/document.createTextNode “Welcome to picture-gallery”))))

(defn init! [] (mount-components))

01 Aug 2017, 21:51
Dmitri Sotnikov (136 posts)

I’m not sure what this code is meant to be doing

(defn mount-components []
  (let [content (js/document.getElementById “app”)]
    (while (.hasChildNodes content)
        (.removeChild content (.-lastChild content)))
        (.appendChild content (js/document.createTextNode “Welcome to picture-gallery”))))

You want to mount the root element using something like:

(r/render [home-page] (.getElementById js/document "app"))
01 Aug 2017, 22:20
Justin Calcagni (17 posts)

The code was part of the template (I assume since I didn’t write it) and on page 151, there is a snippet given for page [] so I wasn’t sure what to delete and what to keep (the sample code is from further along in the chapter as well so it isn’t obvious)

I have made the changes suggested and no modal box. I have followed the code from 151 to 155 and same result. I even wiped out my entire picture gallery app and regenerated & modified everything but when I get to this point I have the same result (white screen “Welcome to picture gallery”

I am sure I am not understanding and making mistakes but it’s very frustrating to try and follow along and it’s not obvious which commands to run in which namespace in which order and which files to modify and what they should look like after I’m done…and even when I do manage to figure it out by looking at sample code, reading the forums, etc I don’t get the results in the book. I feel like I’m no closer to having an app running or understanding what is going on with Clojure

01 Aug 2017, 22:26
Dmitri Sotnikov (136 posts)

Sorry to hear you’re having trouble getting through the book. Unfortunately, I’m not able to reproduce the issues you’re experiencing I’m also not certain how the code you pasted was generated as it’s not part of the template.

One thing to try would be to run the project from sample code to see if it works on your system.

02 Aug 2017, 01:55
Justin Calcagni (17 posts)

used the sample code. no luck. same problem. I see the swagger-ui but if I just navigate to localhost:3000 all I get is a page telling me compile clojurescript and then it jumps to a simple page with “welcome to picture-gallery” and that’s it. no modal, nothing at all from page 151-161.

I used sqlite and got as far as page 149/150. I jumped through all the hoops to get PostgreSQL running on my windows machine and walked through all the code to create the database so I could run picture-gallery-a using the sample code to no avail.

I really don’t want to keep trying and go on because I can’t see if it works. Sorry to be “that person” but this has been a complete waste of my time and money. I have typed in the code, copied/pasted the EXACT Code, copy/pasted the sample code and used the sample code directly. I am at a complete loss of what to do or what is wrong

02 Aug 2017, 02:01
Justin Calcagni (17 posts)

I ran this command again, just because

lein new luminus gallery +auth +swagger +cljs +sqlite

I navigate to src/cljs/gallery/core.cljs and opened it here’s what’s in the file

(ns gallery.core)

(defn mount-components [] (let [content (js/document.getElementById “app”)] (while (.hasChildNodes content) (.removeChild content (.-lastChild content))) (.appendChild content (js/document.createTextNode “Welcome to gallery”))))

(defn init! [] (mount-components))

I didn’t write this. I didn’t create it by hand. it had to come from the framework

02 Aug 2017, 02:07
Dmitri Sotnikov (136 posts)

Have you followed the step from chapter 1 to set the template version to the one used in the book:

By default, Leiningen will use the latest version of the template that has been published to the Clojars repository. Therefore, the skeleton projects generated by the template may not be exactly the same as the ones discussed in the book. In order to ensure that you’re able to follow the book exactly, I recommend adding the following plugin reference in the ~/.lein/profiles.clj file. This will ensure that the projects are generated using the same version of the template that was used in the book.

{:user {:plugins [[luminus/lein-template ""]]}}

In order to tell Leiningen that we want to use a specific template for the project, we must specify it as the argument following the new parameter when running lein, followed by the name of the project. Any other parameters will be passed in as the arguments to the selected template.

02 Aug 2017, 02:11
Dmitri Sotnikov (136 posts)

The template went through a few revisions since the book was released. The +cljs profile used in the book is now called +reagent.

You must be logged in to comment