Prototype for JQuery - how to access the event creator
I come from Prototype background and am learning JQuery. I would like to know the "correct" way to attach a click event to a group of elements, but then know in the event handler which of my elements was clicked.
I came up with the following:
MYNS.CarouselHelper.prototype.attachImgHandlers = function () {
$j(".carouselItem").bind("click", this, function(e){ e.data.openCarouselImage(e) });
}
Then I have this in my event handler:
MYNS.CarouselHelper.prototype.openCarouselImage = function(e) {
var img = e.currentTarget;
// Do stuff to the image element
};
It is right'? This is not correct for me, as I am used to passing an element explicitly to an event handler in Prototype when I iterate over an array of elements.
+2
a source to share