I'm attempting to build a map dashboard using D3 - there are four dropdowns that the user has to select. Each of these dropdowns will filter out different parameters from a large dataset.
Selecting all of them will give me the data needed to make a map. I would like to run the drawMap function only after these four dropdown options have been chosen.
I know that one can do the below;
document.getElementById("#idofdropdown").addEventListener("change",function(event){
RUNFUNCTION();
});
How does one do this in case of multiple events? This question seems to look for a similar solution using bind, but developers suggest that isn't good practice.
In that case, what other ways can one go about this problem?
UPDATE I figured this out. I keep a count, for the first four times you make a choice it increments and then runs the function, and for subsequent changes - it runs the function again and again. Exactly what I needed.
count = 0
$(function() {
$('.dropdown').change(function() {
count = count + 1
if (count > 4) {
count = count - 1;
}
if (count == 4) {
RUNFUNCTION();
}
});
});