The problem is that when I delete an item, the rest of items are hidden, not only the one that is deleted.
Before I just used a simple eventIsActive: true in data() and set it to false in the removeEvent(). Was easier to use it, but because I have ShowItems.vue(list version), too, if I delete an Item in grid version, in the list version will still be there, until I refresh the page.
Never mind, someone else helped me. I saw that nobody from here has no idea how to help me so I asked on other place.
"Come back to your first try, without Vuex.
In your case you need to reload the page to hide that item in the other page version. I recommend you to use splice to be sure that the item is deleted.
You can replace the eventsList with you array.
Please try this code, declaring the eventIsActive in the data():"
I wouldn’t jump to conclusions… there are a lot of knowledgeable people that hang around here, but we also have lives and day jobs (and sometimes just miss threads)
The problem with your code seems to be that you’re setting a single property in your store (eventIsActive) and using that to determine whether to show or hide each event, but there is nothing there identifying which event and so as soon as the property is set to false all events are hidden.
The non-vuex example you were given is on the right lines, but it’s obviously actually removing events from the eventsList rather than just hiding them, which wasn’t what you originally asked. It’s also reloading the page after a timeout, which should be completely unnecessary, as Vue should automatically rerender the list once events are removed from the list.
If you wanted to do this with Vuex, you’d need to move your logic that removes an event from the list into a store mutation, and the Ajax code into an action that then dispatches that mutation once the request has completed. The component itself would then no nothing of how the list is mutated or the changes are persisted to the server - it just dispatches the action.