Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save order of multiple lists to localstorage? #2360

Open
neviln opened this issue Mar 25, 2024 · 0 comments
Open

How to save order of multiple lists to localstorage? #2360

neviln opened this issue Mar 25, 2024 · 0 comments

Comments

@neviln
Copy link

neviln commented Mar 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant