[Vuejs]-Keep track of objects updates in vue.js

0👍

Add an editedTitle: '' property to you object and set it as v-model.

now add a onblur event listener to the input and push the item to another array if inputs title is edited

<ul>
    <li v-for="item in items" :key="item.id">
        <input v-model="item.editedTitle" @blur="addToUpdated(item)/>
    </li>
</ul>

data(){
    return {
        items;[],
        updatedItems:[]
    }
}
methods:{
    addToUpdated(item){
        if(item.title !== item.editedTitle){
            this.updatedItems.push(item);
        }
    }
} 

Leave a comment