I'm trying to create a table that contains a bunch of input text fields. My goal is to get the value of an input, and add it into an object with the row ID as the key. I tried to use v-model, but I lost. I actually managed to get all necessary pieces, but I couldn't put them together. So, I hope someone can help me on that.
Here is my input box:
<input
type="text"
:id="['tv_code_' + listItem.asset_id]"
@input="getInputValue('tv_code', listItem.asset_id)"
>
The function:
getInputValue(obj, key) {
var inputValue = document.getElementById(obj + "_" + key).value;
if (inputValue.length > 0) {
this.$set(this.form.obj, key, inputValue);
} else {
this.$delete(this.form.obj, key);
}
}
And vue.js data structure:
data(){
form: new Form({
tv_code: {}
})
}
When I type something in the input, I'm getting these 3 errors:
[Vue warn]: Cannot set reactive property on undefined, null, or primitive value: undefined
[Vue warn]: Error in v-on handler: "TypeError: Cannot use 'in' operator to search for '1' in undefined"
TypeError: Cannot use 'in' operator to search for '1' in undefined
I don't understand what is undefined because when I try console log obj, key, and inputValue, I'm getting the correct values.