// put all selected samples into array
updateSelectedSamplesArray(obj, event) {
let index = this.selectedSamplesArray.indexOf(obj);
if (index === -1) {
if (event.target.checked) {
return this.selectedSamplesArray.push(obj);
}
} else {
if (!event.target.checked) {
return this.selectedSamplesArray.splice(index, 1);
}
}
}
But now I need to do the same thing when the parent div is clicked (the one with the classname of “sample”). How can I do this? Obviously, the $event differs in parent div click and on checkbox change, so I can’t reuse my updateSelectedSamplesArray function.
you use input when you should be using ion-checkbox
you don’t close your input tag; see this page to copy and paste working code
your code relies on both [checked] and [value], but it should only use [checked]
your (change) code does 2 actions: it calls a function as well as executes in-line code; for simplicity’s sake & for the readability of the code, only do one or the other (in this case, only make a call to a function & do all work there)
when creating ID values, stick to the same standards used when creating variable names (don’t call them 1, 2, 3, etc)
@Smirnova, if you have any questions with my code, let me know. I’m not certain if my 2 separate objects (fish and bears) replicate the issue you’re having with your sample items.
The advice about not using any, ever, is probably the single most helpful piece of advice I’ve received on this forum. I was kindof abusing it. It saves you a ridiculous amount of time in the long run. It’s just a pain for a hot minute.