You could move it to your viewmodel if you pass the parent and its index:
vclick: function(data, evt) {
$root.vclick(data, event, $parents[1], $parentCountext.index());
}
Then in your viewmodel it might look like this:
self.vclick = function(data, event, parent, rowIndex) {
parent.cellClick(parent.rows()[rowIndex], data, event);
};
But this does not feel right. If you could share some more code (cellClick
?), we can determine whether there's a better approach.