First, apologies for asking something that must be answered here somewhere (I've been looking!)
I want to do this:
var i;
for (i = 0; i < 5; i++) {
...
// Add an anchor to the dom
...
a.onclick = goog.bind(this.doSomething, this);
...
}
namespace.Clazz.prototype.doSomething = function(event, index) {
console.log('index: ' + index);
}
I want 5 anchors the each pass a different value for i
to doSomething
when clicked (along with the click event). I also want to keep the context of this
in doSomething
(hence the bind).