...
In this example, this would be bound to each element in turn retrieved by the selector $('li') and processed in the each loop. techniques of this sort pull this off by explicitly passing a value for the implicit this to the target function as an argument to the call method. In other words, something (in spirit) like:
| No Format |
|---|
(defn f [] (.x js/this))
(f)
;=> #<[object Global]>undefined
(.call f (js* "{x : 9}"))
;=> #<[object Object]>
9
|
This is effectively what goog.bind does, so this type of behavior should just work using ClojureScript functions.