Javascript function fails to return element
You are using .each()
with a function
.each(function(){
...
return this;
});
return false;
This will return from the callback (and maybe stop the each-loop if this
was false
), but never break out and return from the outer getCurrentCell
function! So, that one will always return false
.
Quick fix:
var result = false;
<...>.each(function(){
if (<condition>) {
result = <found element>;
return false; // break each-loop
}
});
return result; // still false if nothing found
Currently there is a better way to get currently selected in Handsontable. Just use the following methods from Handsontable:
handsontable('getSelected')
- Returns index of the currently selected cells as an array [topLeftRow
,topLeftCol
,bottomRightRow
,bottomRightCol
]
handsontable('getCell', row, col)
- Return element for givenrow,col
All methods are described here: https://github.com/warpech/jquery-handsontable