How to save order of multiple lists to localstorage?
neviln opened this issue · 0 comments
I've read the help page (https://github.com/SortableJS/Sortable?tab=readme-ov-file#store), which helped me learn how to save the order when using a single list, but didn't know how to apply it when using multiple lists.
I also went through many of the previously posted issues, but am still lost. I did find one similar issue (#568) but was not able to figure out where to insert the "store" portion of the code:
store: {
get: function (sortable) {
var order = localStorage.getItem(sortable.options.group.name);
return order ? order.split("|") : [];
},
set: function (sortable) {
var order = sortable.toArray();
localStorage.setItem(sortable.options.group.name, order.join("|"));
}
};
I made a sample JS Bin (https://jsbin.com/rakuzop/edit?html,js,output) and my goal is to be able to move items around between the 4 todo lists and have the order of all lists saved to localstorage. I tried to implement the solution @RubaXa suggested in issue 568, but wasn't able to get it to work. Currently, it only saves the order of 'Todo 4' list.
I'm new to JS and have been trying to get it working for weeks. Any help is greatly appreciated. Thank you