Let's take some pseudo-Mootools code:
for loop (i) from 0 to 5 {
create.element {
id: 'element_'+i
}
$('element_'+i).addevent.click {
alert(i);
}
}
The events get added to the elements properly. However, when clicked, they'll all alert the latest iterator... which would be 5.
Is there any way I can change "alert(i)" in the event to alert the iterator at that point in time?
.toString didn't do much.