Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attaching an event handler

I have a event handler called some-handler and a event called someevent following works when doing it in javascript,

window.onsomeevent = space.some_handler;

I have been googling for nearly an hour but I can not find how to do this in clojurescript?

like image 378
Hamza Yerlikaya Avatar asked Nov 04 '11 14:11

Hamza Yerlikaya


1 Answers

Here's a snippet to add a mousedown listener to window. Look here for the other google closure event types: http://closure-library.googlecode.com/svn/docs/closure_goog_events_eventtype.js.source.html

(ns example
  (:require
   [goog.dom :as dom]
   [goog.events :as events]))

(def w (dom/getWindow))
(events/listen w (.-MOUSEDOWN events/EventType) #(js/alert "Handle Mouse Down"))
like image 154
Upgradingdave Avatar answered Sep 28 '22 06:09

Upgradingdave