I am looking for a way to pass an object through a function and then dynamically add a table row with the data from that object. In my backend, I need to first send the "row" object to the function. While I know how to add table rows using vanilla JS and jQuery, I am unsure of how to accomplish this in VueJS. Can you provide guidance on achieving this?
HTML TABLE
<table id="tableID"></table>
HTML CODE NEEDED TO BE ADDED USING THE DATA FROM THE "ROW" OBJECT
<tr v-for="item in items" :key="item.Id" v-bind:id="item.Id" class="e-tr">
<td><input type="text" class="c-cell" v-model="item.Type"/></td>
<td><input type="text" class="c-cell" v-model="item.Model"/></td>
</tr>
JAVASCRIPT
add: function () {
var row = { Id: 0, Type: 0, Model: 0 };
fetch('/Cont/Send', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(row)
})
.then(function (response) {
return response.json();
})
.then(function () {
/*insert additional HTML code here?*/
})
}