Skip to content

Instantly share code, notes, and snippets.

Last active September 23, 2015 13:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
This is the parent with the state that I want one child to be able to change and that triggers the render which looks at local state and then changes
(defn section-button-view [title-and-symbol-vector owner]
[:div {:style {:color "black"
:border "1px solid grey"
:border-radius "4px"
:padding "5px"
:margin "5px"
:text-align "center"
:font-weight "bold"
:background-color "lightgrey"
:font-size "2rem"
:on-click (fn [event]
(js/alert (str "Hello from " (first title-and-symbol-vector)))
(om/set-state! owner :section-visible (second title-and-symbol-vector))
(first title-and-symbol-vector)])))
(defn editor-sections-buttons-view [data owner ]
(render [this]
; [:h1 "Sections"]
(om/build-all section-button-view [["Basic Info & Photos" :info]
["Amenities" :amenities]
["Campsites" :campsites]
["Rates" :ratess]
["Policies & Restrictions" :policies]]
(defn setup-middle [data component]
(init-state [_]
{:section-visible :info})
(render-state [_ state]
[:hr {:style {:margin "2rem"}}
[:h4.two.columns {:style {:border-style "solid"
:background-color "WhiteSmoke"
:border-width "1px"
:padding "20px"
:margin "0px"}}
(om/build editor-sections-buttons-view data)
(let [current-section (om/get-state component :section-visible)]
(.log js/console "Current section is: " current-section)
(case (name current-section)
"info" (om/build basic-info-and-photos-section data)
"amenities" (om/build amenities-section data)
"default" (.log js/console "Don't have this section done yet!")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment