vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

value disappears #494

Open zzzxtreme opened 8 years ago

zzzxtreme commented 8 years ago

I just can't wrap my head around this "problem". I have textboxes A, B, C, D. And their visibility is conditional. Example, if I select dropdown X, first item, show textbox A. I enter some values in textbox A. then I change dropdown X to another item, to hide textbox A, and show textbox B. then when I try to enter something in textbox B, the value immediately disappears on lost focus. Has anyone encountered this problem before ? I must be doing something wrong, but I can't identify it. A hint, or a clue would be very helpful.

Any help greatly appreciated

simplesmiler commented 8 years ago

Check the console for errors. Demo: https://jsfiddle.net/simplesmiler/Lrk9sxjf/30/

Also, vuejs/Discussion is deprecated. You can find help on forum or gitter.

Cadienvan commented 8 years ago

If you could provide a JSFiddle, it would be helpful in order to provide a proper answer

zzzxtreme commented 8 years ago

hi guys. thanks for the response. I somehow found the issue

let's say an object like this { "name" : "nick", "age" : 25 } . then as usual, i put 2 controls, v-model "name" and "age". if i add another control, v-model="gender", value will "disappear" once the control lose focus. I guess, because "gender" is not a property of that object. so the solution is to assign the "gender" property in javascript, at least to a null value

Cadienvan commented 8 years ago

Yes, I guess your console is providing you a "Cannot find attribute" error or kinda, so Vue.js(As every javascript portion of code) stops working and loses its variables, v-model doesn't work anymore and so input will be empty.