FYI, I already read the related thread Uncaught TypeError: Cannot read property 'toLowerCase' of undefined and tried to implement the idea. Still, I'm getting the classic
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
error and I don't know which line in my code it's coming from because the error points within jQuery. My code is
ReadinessColorSetter = (function () {
this.ColorToRange = {
'#f65314': [0, 30],
'#ffbb00': [31, 70],
'#7cbb00': [70, 100]
}
this.SetReadiness = function (ipt) {
// ipt: input element containing
var val = $(this).val(),
newcolor = "#FFF"; // default
for (var hexcode in this.ColorToRange) {
var range = this.ColorToRange[hexcode];
if (val >= range[0] && val < range[1]) {
newcolor = hexcode;
break;
}
}
$(ipt).parent().children().last().css('background-color', newcolor);
}
return this;
})();
// On page load, set the color of the readiness
$(function () {
$('input[class="completeness"]').each(function (el) {
ReadinessColorSetter.SetReadiness(this);
});
});
// When the readiness value is changed, set the color of the readiness
//$('input[class="completeness"]').change(function () {
//ReadinessColorSetter.SetReadiness(this);
//});
$(document).on('change', $('input[class="completeness"]'), function (el) {
ReadinessColorSetter.SetReadiness($(el.target));
});
$('#change-submitted').click(function () {
alert('Change submitter clicked'); // TEST
});
and as you see I've commented out what I thought was the problem and tried to implement the correct fix.
Any guidance on this issue?
$(ipt).val()
? Check here:this.SetReadiness = function (ipt) {...var val = $(this).val(),
– Keiran Tai