/ Published in: JavaScript
requires mootools
Expand |
Embed | Plain Text
/* Function in class */ prepareLabels: function(dataProperty,defaultEvent){ var i = 0; $each(stageLabels,function(listElement){ listElement.setProperty(dataProperty,i); listElement.addEvent(defaultEvent,function(e){ /* changeImage => other function in class */ this.changeImage(e.target); }.bind(this)); /* bind -> sets function-context */ i++; },this); }
Comments
Subscribe to comments
You need to login to post a comment.

It quite depends on what type of application you are building, but instead of attaching many events to many objects, use event delegation.