Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to debug radio buttons being unchecked randomly

Kindly see: https://jsfiddle.net/chrzrdx/krrczkx5/

This is on vue 2.1.4

I have a questions array in my vue.data, and I'm cycling through them every time the next or prev button is pressed. I store the id of the active question, and compute the active question from there. I am using v-model on the radio button to store the state in the active question's selected property.

The questions already have a default value (selected initially contains the value of the default option). But some radio buttons display as unchecked even though the selected field of the current (active) question is set.

The issue persists even if there are no default values in selected, and the user clicks each button herself.

like image 536
lip Avatar asked Jan 25 '26 05:01

lip


2 Answers

You just need to remove this v-bind:name="active_question.txt" from input tag in HTML, so following will be updated line.

<input type="radio" v-bind:value="o.txt" v-model="active_question.selected">

Working Fiddle: https://jsfiddle.net/krrczkx5/9/

like image 177
Saurabh Avatar answered Jan 26 '26 20:01

Saurabh


In addition to the answer mentioned above, please see this: https://github.com/vuejs/vue/issues/4375

like image 45
lip Avatar answered Jan 26 '26 18:01

lip