I am having trouble getting the index of the selected cell in my table. I have attached a click function to each cell that is supposed to alert the index when pressed but I am unable to get the index properly. The index of the row is correct but the index of the column is always incorrect.
function doSomething(i) {
setTimeout(function() {
for (var j = 0; j < columnNum; j++) {
oTable.getItems()[i].getCells()[j].$().parent().click(function() {
alert(i+", "+j);
});
}
}, i);
}
for (var i = 0; i < rowNum; i++) {
doSomething(i);
}
Here is the full fiddle: https://jsbin.com/hecuhevawe/1/edit?html,css,js,output.