How to connect Bootstrap tooltip to Clojurescript Reagent component

Here is the component that I process at the end of each row of the table. Part of the tooltip does not work.

How can I attach Bootstrap tooltips to each component after it is rendered?

(defn edit-button-component []
    (fn [attrs]
        ^{:component-did-mount #(.tooltip ($ %) (clj->js {:title "Test"}))}
        [:button.btn.btn-default attrs
        [:span.glyphicon.glyphicon-pencil]]))
+4
source share
2 answers

Where is the symbol $from? If it is from a library jayq, then this is normal. If this is plain javascript jQuery then you will need to js/$.

% , :component-did-mount, this, React, DOM. DOM node jQuery $, reagent.core/dom-node. - :

($ (reagent.core/dom-node %))

Btw, (clj->js {:title "Test"}) #js {:title "Test"}

+2

@myguidingstar js/$ DOM node , . , .

, :

(def tooltip
  ^{:component-did-mount #(.tooltip (js/$ (reagent.core/dom-node %)))}
  (fn [message]
    [:img.help {:src "img/help.png", :data-placement "bottom", :title message}]))

, jquery app.js html .

+2

All Articles