Following the suggestion by Lars Kotthoff, I was able to attach the hoverIntent
handler.
nodes.each (d, i) ->
$(this).hoverIntent (-> highlightNode(d, i)), (-> unhighlightNode(d, i))
(code in CoffeeScript)
Naturally, highlightNode
and unhighlightNode
expect D3 elements, not the DOM element. D3's each
function on selections provides both, the D3 elelent (in d
) as well as the DOM element (bound to this
).
I use this
to select the DOM element and call hoverIntent
on it. The handlers for "mouseenter" and "mouseleave" are anonymous functions that call the existing handlers highlightNode
and unhighlightNode
with the respective D3 elements d
.