The alert(i)
onclick bind line is run on 3 divs, but all of them when clicked alert the last set value of i
. I hope what I\'m trying to do makes s
On a tangent, a better way to add click handlers to multiple markers would be add a single click handler to just their container. The HTML could look something like:
...
...
...
You can use generic HTML5 data-* attributes to store arbitrary data.
And the JavaScript would be:
// Updates bar preview box
this.updatePropertyMarkerBox = function (self, BarsID) {
... snip ...
// Add event handler
$("#bmi-" + self.containerId).click(function (event) {
var marker = $(event.target).attr("data-marker");
if (marker) { // Hey, it's a marker!
alert(marker);
}
});