I'm writing a web app that has a simple button. In my d3.js code, I attach a listener function, so that when the button is clicked, I can perform some actions.
I've also written a function in my d3.js code that performs an alert.
The problem is that while the onclick listener works (it successfully calls an alert), it doesn't call the function that I wrote. Here's my code:
do() {
alert("ha");
}
componentDidMount() {
d3.select("body").select("#filterButton").on("click", function() {
alert("hi");
this.do();
});
}
The alert inside the onclick works, but do() isn't called (I'm not getting a second alert). Why is this so?