neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

Can I call a function within an eventhandler? #399

Open sofiaps opened 5 years ago

sofiaps commented 5 years ago

Hi, I am trying to call a function when a region has been clicked and pass the target dataset as an argument, but the code below doesn't seem to be working : eventHandlers:{ click: function getArea(event) { this.handleTarget(event.target.dataset);} } I keep getting an error that the function is not defined. Is there a way to achieve that?

neveldo commented 5 years ago

Hello @sofiaps ,

Did you achieved to find a solution ? In the other case, could you provide a complete JSFiddle example of your work in progress ? It would be easier to see what is wrong. Maybe if you want to use "this" (for handleTarget()) in your callback, you should use an Arrow function instead.