Closed geosem42 closed 5 years ago
I had to pass the arguments to the function on the @checkedChange
event, like so
@checkedChange="onCheckChange(task, index, $event)"
@geosemaan Hello, I had a problem similar to yours, and looking at your code I had an idea, I tested your code but when selecting a radio it did not deselect the other. Here is an example code:
<StackLayout class="nt-input">
<ListView
ref="lista"
height="150"
for="(answer, index) in answers"
>
<v-template>
<GridLayout columns="*" rows="*">
<CheckBox
:text="answer.option"
:checked="answer.checked"
@tap="handleCheckChange(index)"
col="0"
boxType="circle"
/>
</GridLayout>
</v-template>
</ListView>
</StackLayout>
Script
data() {
return {
answers: [
{ id: 0, option: "One", checked: false },
{ id: 1, option: "Two", checked: false },
{ id: 2, option: "Three", checked: false },
],
};
},
methods: {
handleCheckChange(index) {
for (let a of this.answers) {
a.checked = false;
}
this.answers[index].checked = true;
this.$refs.lista.nativeView.refresh();
},
}
Hello,
I have a checkbox inside a
ListView
component that has afor loop
I need to get the index number of the checked item so I can remove/modify it in the array but I'm unable to do that as there's no
:key
prop like in Vue.This is how I'm rendering the list. I'm still new to mobile apps development so I'm not sure whether to use a
Label
with the checkboxes or just use thetext
attribute to add the text. WHat is the normal convention here?I can get the index number of the item with
@itemTap
onListView
. However, it stops working when I add@checkedChange
to theCheckBox
tag.Also something minor I found, I am unable to tap the checkbox to change its state (click in my case since im using an emulator). I have to tap on the text associated with it
:text="task.title"
and if I remove the text, I have no way to toggle its state.The javascript