Topic: Sortable - how to save state/order
Hi - any suggestions on how to save the state once a user has re-ordered a list using your sortable plugin?
Thanks, Shaun McArthur
Damian Gemza staff answered 6 years ago
Dear Shaun,
There's no built-in feature like your desired behavior in our Sortable Plugin.
What can I advise you? After reordering the list by the user, you should read the list order with document.querySelectorAll()
or something like this, and try to save the actual order in database/cache/indexedDB.
I have no other idea to advise you.
Best Regards,
Damian
mdeak pro premium priority answered 5 years ago
What about providing a name/value pair in the list-group, submitting a form, and then reading the values from the submitted form fields?
Mateusz Łubianka staff commented 5 years ago
Hi, It good idea. I think the best way is save order after submit event in database. For example Firebase.
Best,
shamca answered 5 years ago
Both good solutions, I can drop the key/values in redis or local to the browser's IndexDB and pull them down asynchronously.
Cheers, Shaun
lemons commented 5 years ago
You could also store it as cookie. Cookies can be accessed from JS as well as from the backend. You could also copy the cookie values to your user settings and rebuild the cookie on login in case it was deleted, or the user loggs in from a different browser. Depends on you what you want to archive.
Mateusz Łubianka staff commented 5 years ago
It true. You can use cookies to store your data. https://www.w3schools.com/js/js_cookies.asp
Best,
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.6.0
- Device: Desktop
- Browser: Chrome
- OS: Mac OS
- Provided sample code: No
- Provided link: No