MaxLeiter / sortablejs-vue3

A thin wrapper around Sortable.js for Vue 3
https://sortablejs-vue3.maxleiter.com
MIT License
380 stars 21 forks source link

How to add item to the list or remove item from the list? #110

Open theodol59 opened 6 months ago

theodol59 commented 6 months ago

Good afternoon,

Every item in my list has a remove button. When I press it, I want item to be removed. Additionally, I have a need to add items to my current rendered Sortable component.

It seems that Sortable component doesn't react to removals or additions. In order for Sortable to update itself with new "list" value, I need to pass unique Vue "key" property to Sortable component. Only then Sortable component re-renders itself... But it has many drawbacks as every item looses its rendering state...

Could you give me an example (based on https://github.com/MaxLeiter/sortablejs-vue3/blob/main/src/examples/WithStore.vue) how to add an item to the fruits list and how to remove a fruit from the list so that other items are not mounted again?