0

I need a link in the tooltip text for my d3 scatterplot which invokes javascript

I've read this: http://bl.ocks.org/d3noob/c37cb8e630aaef7df30d.

And I removed 'pointer-events: none;' from the css of my tooltip as required.

  • I've tried setting the href in the link to both '#' and 'javascript:void(0)'.
  • I've tried using a jquery click handler ($('a.my-class').click(function(){...})).

Nothing has worked. When I click the link the javascript is not invoked. If I set the href to a URL and click the link, however, the browser does go to the URL I specified.

So why doesn't it work with javascript?

aberna
  • 5,594
  • 2
  • 28
  • 33
Laran Evans
  • 1,283
  • 5
  • 15
  • 31
  • Are you getting any error messages? What do you mean when you say that it doesn't work? – Lars Kotthoff Feb 25 '15 at 09:13
  • do you have a JSFiddle ? – AJ_91 Feb 25 '15 at 10:55
  • @AJ_91 Here is the actual code in github: https://github.com/laran/eisenhower/blob/master/components/plot/scatterplot.js#L107 Here is where I enable pointer-events: https://github.com/laran/eisenhower/blob/master/components/plot/scatterplot.css#L16 – Laran Evans Feb 25 '15 at 20:14
  • @LarsKotthoff There are no errors. It just doesn't do anything. In the code I've linked above there are no handlers for clicking on the links (matching selector a.tooltip-task-link). As I said, I've tried various methods, none of which worked. – Laran Evans Feb 25 '15 at 20:15
  • Have you tried simply calling the Javascript function in the `href` as e.g. in [this question](http://stackoverflow.com/questions/5003867/how-to-call-javascript-function-instead-of-href-in-html)? – Lars Kotthoff Feb 26 '15 at 08:44

0 Answers0