I'm amazed by what vuejs brings to the table, but I'm hitting a wall at the following. I have an input text field with a v-model attached, and every time someone hits the "add" button, another input text get added to the DOM with the same v-model attached. I thought I'd then get an array of the v-model values, but it only gets the value of the first v-model input:
<label class="col-sm-2" for="reference">Referenties</label>
<div class="col-sm-6">
<input v-model="find.references" class="form-control" type="text">
</div>
<div class="col-sm-2">
<button @click="addReference" class="form-control"><span class="glyphicon glyphicon-plus"></span>Add</button>
The html I append to the dom is triggered by the addReference method:
addReference : function (e) {
e.preventDefault();
console.log(this.find.references);
div = '<div class="col-sm-6 col-md-offset-2 reference-row"><input v-model="find.references" class="form-control" type="text"></div>';
$('#references').append(div);
}
Is this something Vuejs can't do? Is there a different approach of gathering values from dynamic dom elements with Vuejs?