Fork me on GitHub

I’ve been trying to make a devcard for an Om component, but it requires a target element. I’ve tried to use the dom-node macro. Anybody know how to pass it to Om? Here’s my code: (defcard-om campaign-countdown (om/root timer/countdown-timer timer-state {:target (dom-node)}))

Daniel Jomphe19:12:30

@sventechie: Hi Sven, see this:

    (om/mock-root reconciler YourDataScriptBackedComponent))

Daniel Jomphe19:12:34

Another example, less powerful:

(def input-nam-letters (om/factory InputNamLetters))

  (fn [init-data _]
    (input-nam-letters @init-data))
  {:nam-letters "Blah"}
  {:inspect-data true
   :history true})


Hmm, I still get the error: "Card has not mounted DOM node."

Daniel Jomphe19:12:16

In both cases I didn't need to pass the target node (but I may have misundestood your need on that level)

Daniel Jomphe19:12:32

What version of devcards?


OK, looks like maybe you’re using

Daniel Jomphe19:12:42

oh, yes, sorry! And I never used Om.current


I’d be happy to port it to but not sure how involved that’d be.

Daniel Jomphe19:12:23

ok, then try

(defcard-om campaign-countdown
            (fn [init-data node]
              (om/root timer/countdown-timer timer-state
                       {:target node})))


Yeah, I looked at Bruce’s examples but he never uses the macros I think I’d need.


I’m still getting "Card has not mounted DOM node.” with your example.


Where did you get the argument list?

Daniel Jomphe20:12:32

Also check the bottom of the page.


Hmm, thanks, Google searches did not turn up those documents.


node appears to be a React element, rather than a DOM element. I wonder if that’s a problem.

Daniel Jomphe20:12:28

ok so the bottom of that page will tell you how to reach a DOM element.

Daniel Jomphe20:12:47

Note: I haven't looked at if you really need the low-level of a DOM element for that counter.


Thanks! I’m asking the more general question in the #om channel now.