使用 Closure 庫向 Button 新增事件

(ns so-doc.events
  (:require
   [goog.dom :as dom]
   [goog.events :as events]))

(defn handle-click [event] ;an event object is passed to all events
  (js/alert "button pressed"))

(events/listen
 (dom/getElement "button"); This is the dom element the event comes from
 (.-CLICK events/EventType); This is a string or array of strings with the event names. 
;;All event names can be found in the EventType enum
 handle-click ;function that should handle the event
 )

Google Closure 不支援頁面載入事件,並認為它們不是慣用的。他們建議在載入訪問的內容後立即插入指令碼。