I have the following js function and I’m pulling my hair out trying to determine why it won’t return ‘true’. I’ve verified the logic block is being hit by adding an alert into the block but it seems to skip the line containing the return statement.
function requiresMatchLevel(fields) {
$.each(fields, function (i, field) {
if (field.OperationParamName() == "MatchLevel" && field.Include()) {
return true;
}
});
return false;
};
returnacts on a per-function basis. Returning in the function passed to$.eachwill not have your outer function return something.If you return something in the function passed to
$.each, jQuery will receive the result. The only value that has effect here isfalse, which makes jQuery break out of the loop.