practice / blog

For personal blogging
1 stars 0 forks source link

How to use jQuery from ClojureScript #23

Open practice opened 8 years ago

practice commented 8 years ago

출처: https://gist.github.com/thorstadt/1096382

참고: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/

그대로 옮겨 보자.

(ns jquerytest.core)

(def jquery (js* "$"))    ; js*는 스트링을 받아서 javascript 코드로 실행한다.

(jquery
   (fn []
     (-> (jquery "div.meat")
         (.html "This is a test.")
         (.append "<div>Look here!</div>"))))

; 참고로 browser repl에서 다음을 실행하면 alert가 실행됨.
(js* "alert('my special JS code')") ;; JS output: alert('my special JS code');