1

I'm using d3 to render circles that represent each of the elements in my database. Each circle ends up looking something like this:

<circle r="8" fill="#585858" stroke="#008db7" stroke-width="3" id="Node;R6AnePqKecNNe7dkr" class="R6AnePqKecNNe7dkr"></circle>

I can use the following to return "success" when any of the circles are clicked:

Template.tree.events({
  'click circle': function(){
    console.log("success")
  }
}); 

but instead of "success" I'd like to return the class of the circle that was clicked.

If I console.log(this) I get 'Object {}' so my instinct tells me to use this.class but that doesn't return anything.

Josh McGee
  • 443
  • 6
  • 16

1 Answers1

1

found in the answers here the following code solves the problem

Template.tree.events({
  'click circle': function(e){
    console.log(e.currentTarget.getAttribute('class'))
  }
}); 
Community
  • 1
  • 1
Josh McGee
  • 443
  • 6
  • 16