SortableJS / ngx-sortablejs

Angular 2+ binding to SortableJS. Previously known as angular-sortablejs
https://sortablejs.github.io/ngx-sortablejs/
MIT License
466 stars 160 forks source link

How does the Store method work with localStorage? #154

Open gregAnd opened 5 years ago

gregAnd commented 5 years ago

I would like to save my list with localStorage for that I use the method store and set (), when I reload the page even if the localStorage saves the good positions, on the screen display does not conform is restitutes the initial orde of the elements.

I am attaching an example

https://stackblitz.com/edit/sortable-localstorage

If you have a solution, I'm interested

smnbbrv commented 5 years ago

hi @gregAnd

the store is not recommended for angular. Instead, just listen to the onUpdate / onAdd / onRemove (depending on what you have) event and save your items in there. When you load the component, get it from the place you store it back. Quite simple. Store is just unnecessary here

gregAnd commented 5 years ago

hi @smnbbrv

Thank you for your quick reply.

I will use the event list to save.

gregAnd commented 5 years ago

Would you have an example because the I do not see really sent yet and recover the localStorage.

If I use onEnd () to store the event in localStorage, how can I get it back if I refresh the page.

I thought I was using onUpdate () but it does not activate when reloading the page.

Sorry but there is a lot of information on this subject.