On Wed, Apr 9, 2014 at 6:03 AM, Florian Salihovic <
[email protected]> wrote:
> (defn add-task-view
> "Component used to add new tasks."
> [app owner]
> (reify
> ;; when not implemented, add-new-task will throw an error is
> app is passed.
> om/IInitState
> (init-state [this]
> {:tasks (:tasks(:project app))})
>
> om/IRenderState
> (render-state [this state]
> (.log js/console "add-task-view#render-state")
> (dom/div nil
> (dom/h3 nil (i18n :task))
> (dom/label nil
> (i18n :title)
> (dom/input #js {:type "text" :ref "new-task-title"}))
> (dom/label nil
> (i18n :description)
> (dom/input #js {:type "text" :ref "new-task-description"}))
> (dom/label nil
> (i18n :tags)
> (dom/input #js {:type "text" :ref "new-task-tags"}))
> (dom/div nil
> (dom/button #js {:onClick #(add-new-task (:tasks state)
> owner)} "☑"))))))
>
> So my question basically is: is my soluation "idiomatic/clean" solution
> when creating data in Om.
>
Looking at this a bit more closely the last line is the real issue,
`(:tasks state)`. I assume previously that was `(:tasks app)`. That won't
work and this is in fact covered in the first tutorial explicitly. You need
to access `(:tasks state)` outside the event handler where it is an allowed
operation:
(let [tasks (:tasks app)]
(dom/div nil
(dom/button #js {:onClick #(add-new-task tasks owner)} "☑")))
HTH,
David
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.