I have the following code that is repeated some times, with only some variation:
$('#mapContainer').on({
mouseenter: function () {
Map.ApplyEvents.Country(this.id);
},
click: function () {
Map.Zoom.State(this.id);
}
},
'.mapaCountry path');
// this is in another function
$('#mapContainer').on({
mouseenter: function () {
Map.ApplyEvents.State(this.id);
},
click: function () {
Map.Zoom.County(this.id);
}
},
'.mapaState path');
In all events, I have to call an anonymous function just to call 1 function inside.
Is there a way to squeeze this code assigning handler to desirable functions, but also informing parameter with this.id?
I want to achieve something like this:
(note: I know that it's wrong syntax.)
$('#mapContainer').on({
mouseenter: Map.ApplyEvents.Country(this.id),
click: Map.Zoom.State(this.id)
},
'.mapaCountry path');
$('#mapContainer').on({
mouseenter: Map.ApplyEvents.State(this.id);
click: Map.Zoom.County(this.id)
},
'.mapaState path');