Fork me on GitHub
#devcards
<
2015-12-21
>
sventechie15:12:18

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:

(defcard
    (om/mock-root reconciler YourDataScriptBackedComponent))

Daniel Jomphe19:12:34

Another example, less powerful:

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

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

sventechie19:12:16

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?

sventechie19:12:32

OK, looks like maybe you’re using om.next?

Daniel Jomphe19:12:42

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

sventechie19:12:09

I’d be happy to port it to om.next 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})))

sventechie19:12:05

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

sventechie19:12:51

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

sventechie19:12:22

Where did you get the argument list?

Daniel Jomphe20:12:32

Also check the bottom of the page.

sventechie20:12:50

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

sventechie20:12:34

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.

sventechie20:12:51

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