I am calling initListeners to attach listeners to a number of elements with a r#c# ID. The event should trigger a call to another function which takes two parameters identifying the elements r# and c#.
For some reason, I only get 8:8 out of this for all cells... My guess is that it's a referencing issue. Can anyone suggest a fix?
ModelBoard.prototype.initListeners = function() {
var r=0, c=0;
for(r=0;r<=7;r++) {
for(c=0;c<=7;c++) {
$("#r" + r + "c" + c).click(function(){
board.click(r, c);
});
}
}
}
ModelBoard.prototype.click = function(r,c) {
alert(r + ":" + c);
}