Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

valorisdev's avatar

Vue doesn't detect changes on a Javascript array (filter / splice)

Hello,

I am on Vue 2.5.16

I have a JS array of objects at the top of my view , which is populated by my controller. It looks like this :

[{ id: 1}, { id: 2}, { id: 3}, { id: 4}]

I'm using this array at a source for displaying data, and thanks to Vue, it refreshes when I push some data into it.

However, when I try to delete an element from its ID, like so :

let id = 1 // id is retrieved when user clicks on element
  if (ajax.readyState === 4 && (ajax.status === 200)) {
                    myArray = myArray.filter(item => item.id !== id)
                }

It doesn't work.

I've read into this : https://forum.vuejs.org/t/vue-js2-renders-array-with---ob---observer/12426/2 and this : https://vuejs.org/v2/guide/list.html

but I cannot make it work.

Any help will be appreciated

0 likes
2 replies
valorisdev's avatar

Thanks for your help Robstar. Unfortunately I still cannot make it work. I must be missing something so I'm watching again some lessons on Vue.

Hopefully i will understand what you linked in a few days.

Thanks !

Please or to participate in this conversation.