Search code examples
clojureclojurescriptom

OM how to add class to html element


Trying out OM, ReactJS and ClojureScript. I am trying to add a classname to my dom element. Ideally I want something like this:

<div>
    <i class="icon-alert">Contact list</i>
</div>

right now: It writes like:

<div>
    <i>Contact list</i>
</div>

This is my core.clj

(defn new-view [data owner]
  (reify
    om/IRender
    (render [this]
      (dom/i #js {:class "icon-alert"} "Contacts list")
               )))


(om/root new-view app-state
  {:target (. js/document (getElementById "row1"))})

This is the relevant part from my index.html

<div id="row1">
      <h2>Figwheel template</h2>
      <p>Checkout your developer console.</p>
</div>

Any ideas of what I am doing wrong?


Solution

  • Playing around with my code, make me realise: I was writing class instead of className. Feel so dumb. It works now. I will let it here so people with the same issues can get the help they need.

    (defn new-view [data owner]
      (reify
        om/IRender
        (render [this]
          (dom/i #js {:className "icon-alert"} "Contacts list")
                   )))