So let's start with my code:
<button v-on:click="addTextbox">Add</button>
<div id="container">
<div class="row">
<div class="input-field col s12 m12 l12">
<input id="full_name" type="text" v-model="full_name">
</div>
</div>
</div>
So that is basically the code. It outputs a single textbox and what I wanted to do is whenever I click on the Add button, it will automatically generate that whole html (from <div class="row"> to </div>).
So I researched and tried this:
addTextbox: function() {
var container = document.getElementById("container");
var input = document.createElement("input");
input.type = "text";
container.appendChild(input);
}
It adds a textbox but I have problems here:
First is that it only creates a new textbox but I need it to create the whole row div.
Second is that I want each textbox to have a unique v-model. For example the first one is v-model="full_name" and when I add a new one, it should be like this:
<div id="container">
<div class="row">
<div class="input-field col s12 m12 l12">
<input id="full_name" type="text" v-model="full_name">
</div>
</div>
<div class="row">
<div class="input-field col s12 m12 l12">
<input id="full_name2" type="text" v-model="full_name2">
</div>
</div>
</div>
Is there a way to do this? Thank you in advance.