Watch array for changes and prevent items to be empty

Posted 2 months ago by ahoi

Hello everybody,

I got an array of objects like this:


    price: 1,
    factor: 1
    price: 1,
    factor: 2

Now I would like to create a watcher, that prevents price or factor to be empty. If it is, it automatically should be set to 0.

I would do it like this:

'item.list': {
    handler: function (val, oldVal) {

        //how to get the key of the changed object here? 
    deep: true

But unfortunately I don't get the key of the changed element?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.