crazy_phage
crazy_phage

Reputation: 548

using clojurescript with jquery?

Here is what i am trying to do, I can replace Dom with jQuery, but I don't know how to get the Dom value. That's shame.
Gist
This is a gist which I followed it.
So I ask the origin author, but no response yet. PS: I just want to try some cljs in browser, so I didn't use any lib like jayq. I have tried something like (.val "yes"), but it seems to be wrong.

(ns hello-world.jquerytest)
(enable-console-print!)
(def jquery (js* "$"))

(defn x []
  (-> 
    (jquery ".meat")
      (.html "yes")))

(jquery
  (fn []
    (x)
    (-> (jquery "li.numbers")
      (.html "pink")
      (.append "banana"))))

Upvotes: 1

Views: 2608

Answers (1)

crazy_phage
crazy_phage

Reputation: 548

Here is my answer based on Vanessa's comment I tried

(defn x []
  (->  
    (jquery ".meat")
    (.html)
    (println)))

It will print the value which I want. If I am using doto It will print #<[object Object]> in console which I do not want.

(defn x []
  (->  
    (doto
      (jquery ".meat")
      (.html)
      (println))))

Upvotes: 1

Related Questions