Clojure : event listener on domina library

231 views Asked by At

i hope someone can help me on this.

I'm using domina and clojurescript in my website project. My problem is i try to make 3 click event in 3 different button.

I attach the code snippet below,

      (defn html1 []
            (dom/set-inner-html! (dom/by-id "idofhtml") "<h1> lorem ipsum </h1>"))

(defn html2 []
            (dom/set-inner-html! (dom/by-id "idofhtml") "<h1> lorem ipsum2 </h1>"))

(defn html3 []
            (dom/set-inner-html! (dom/by-id "idofhtml") "<h1> lorem ipsum3 </h1>"))

    (defn ^:export init []
        (when (and js/document
            (.-getElementById js/document))
                (ev/listen! (dom/by-id "link1") :click html1)
                (ev/listen! (dom/by-id "link2") :click html2)
                (ev/listen! (dom/by-id "link3") :click html3)))


    (set! (.-onload js/window) init)

Problem is only :

(ev/listen! (dom/by-id "link1") :click html1)

working, the other two :

 (ev/listen! (dom/by-id "link2") :click html2)
 (ev/listen! (dom/by-id "link3") :click html3)

Doesn't work, Thank you in advance, appreciate any help

0

There are 0 answers