Database Reference
In-Depth Information
When we visit http://localhost:3000/int-force and hover over one of the circles, we
will get the following screenshot:
How it works…
This recipe works in the same way as an interaction works on any web page. We listen to events
that the user generates on certain HTML tags. In this case, we pay attention to whenever the
mouse moves over a node on the graph. We bind our event handler to this event in step 7.
When the event is triggered, the event handler is called. In our example, the event handler
function, on-mouseover , is deined in step 6.
The event handler retrieves the data for the node that the user moved their mouse cursor
over, and it calls update-data and dl-item to build the HTML structure in order to display
data about this node.
We've mentioned before that the Google Closure library comes with ClojureScript. In this
recipe, we use its events module ( http://docs.closure-library.googlecode.com/
git/namespace_goog_events.html ) to bind on-mouseover to the appropriate event.
We also use the ClojureScript clojure.browser.dom namespace to delete and create
HTML elements on the ly. This namespace is a thin, Clojure-friendly wrapper around the
Closure library for manipulating the DOM, goog.dom ( http://docs.closure-library.
googlecode.com/git/namespace_goog_dom.html ).
Finally, we also interface a few times with JavaScript itself. We do this by preixing the name of
the JavaScript object or module with js, js/Math , for example.
 
Search WWH ::




Custom Search