Closed ghost closed 9 years ago
I will have to experiment but you should be able to reference 'this'.
hakslor, maybe I misunderstood your question. You can always access the owner in any defsnippet or deftemplate by making it an arg for the function.
(defsnippet tmp "...path..." [:#my-snippet]
[data owner opts]
{[:my-snippet] (lifecycle
{:on-mount (fn [this]
(js/console.log (pr-str (om/get-props owner)))})})
this is also how I solved it on my side. I thought there is a bit more convenient way eg. owner exposed as an additional parameter in lifecycle functions like :on-mount (fn [this owner] ...)
.
anyway, thanks for answer :)
is there any way to access the compoment's owner inside on-mount (and other react events) listener? I would like to call om/get-node and have no idea where should I get the owner from...