I hope you can help as I'm ripping my hair out. For some reason, the filter in the below code doesn't work on IE but it works on every other browser.
values = values.filter( (val => val.value !== $(this).val()) && (val => val.name !== $(this).attr("name") ) );
Below is the full function which is hiding and showing a text area. but the filter is linked to a count so that a file upload box goes when there are no defects on the checklist.
var values = [];
$('input[type="radio"][data-show]').change(function() {
if ($(this).is(':checked')) {
var value = {
"value": $(this).val(),
"name": $(this).attr("name")
};
values = values.filter((val => val.value !== $(this).val()) && (val => val.name !== $(this).attr("name")));
values.push(value);
console.log(values);
var count = 0;
var non_defect_filtered = values.filter(function(d) {
count++;
return d.value === '2';
});
var count1 = 0;
var defect_filtered = values.filter(function(d) {
count1++;
return d.value === '1';
});
//console.log(filtered.length);
if ($(this).val() === '1') {
$(this).closest('div').nextAll('div[data-shown=true]:first').show('slow');
$(this).closest('div').nextAll('div[data-shown=true]:first').children('.required_input').prop('required', true);
$('.file_uploader').show('slow');
} else if ($(this).val() === '2') {
$(this).closest('div').nextAll('div[data-shown=true]:first').hide('slow');
$(this).closest('div').nextAll('div[data-shown=true]:first').children('.required_input').prop('required', false);
}
if (non_defect_filtered.length === values.length) {
$('.file_uploader').hide('slow');
}
if (defect_filtered.length >= 5) {
$('.call_fleet').show('slow');
} else {
$('.call_fleet').hide('slow');
}
}
});
Just so people know the below code filter fixed the issue as => don't work with IE which i never new.
var _this = this;
values = values.filter(
(function (val) {
return val.value !== $(_this).val();
})
&&
(function (val) {
return val.name !== $(_this).attr("name");
}));