(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 does not support page-load events, and considers them to be not idiomatic. They recommend inserting scripts inline as soon as the content they to access has loaded.