Search code examples
clojurescriptom

How can I get the DOM element from an Om DIV?


I am using Clojurescript Om and I need to access the underlying DOM element (so that I can set offsetTop to 0) on one of the DIVs contained in a component. How can I get access to this element?


Solution

  • You can use get-node. There is an example available here.

    Note that the component must be already mounted in order to access its DOM element, therefore you should invoke get-node in one of the Om lifecycle methods that are invoked after the component is mounted (e.g. did-mount).

    If you are using om.next, then you should use the node function instead.