fix: Lors de la selection d'une image le bouton radio doit changer
This commit is contained in:
@ -9,13 +9,10 @@ const props = defineProps({
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
defineEmits(["answerSelected"]);
|
||||
const emits = defineEmits(["answerSelected", "nextQuestion"]);
|
||||
|
||||
const slides = ref();
|
||||
|
||||
if (props.question.weight == null) {
|
||||
props.question.weight = props.question.answers[0].weight;
|
||||
}
|
||||
const answerWeight = ref(props.question.weight);
|
||||
|
||||
function selectAnswer(answer) {
|
||||
@ -26,7 +23,8 @@ function selectAnswer(answer) {
|
||||
}
|
||||
|
||||
function slideMove(splide, newIndex) {
|
||||
props.question.weight = props.question.answers[newIndex].weight;
|
||||
answerWeight.value = props.question.answers[newIndex].weight;
|
||||
emits("answerSelected", props.question, answerWeight);
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -43,7 +41,8 @@ function slideMove(splide, newIndex) {
|
||||
:name="`question_${question.id}`"
|
||||
:value="answer.weight"
|
||||
v-model="answerWeight"
|
||||
@click="selectAnswer(answer)"
|
||||
@change="selectAnswer(answer)"
|
||||
@click="nextQuestion"
|
||||
/>
|
||||
{{ answer.title }}
|
||||
</label>
|
||||
@ -61,7 +60,7 @@ function slideMove(splide, newIndex) {
|
||||
<SplideSlide
|
||||
v-for="answer in question.answers"
|
||||
:key="answer.id"
|
||||
@click="$emit('answerSelected', question, answerWeight)"
|
||||
@click="$emit('nextQuestion')"
|
||||
>
|
||||
<img height="200" :src="`/answers/${answer.image}.webp`" />
|
||||
</SplideSlide>
|
||||
|
Reference in New Issue
Block a user