Sortable: Can you store and get items put/pulled between groups?

Created on 2 Sep 2015  路  4Comments  路  Source: SortableJS/Sortable

See the following http://jsbin.com/jelekuxoli/1/edit?html,js,output where I have two sortable lists. We can move items back and fourth and retain their order on refresh. If I move item between the groups the newly added item is not restored.

Is there a way to do this.

question

Most helpful comment

I think this might be an issue.

I updated @graemegeorge's original fiddle so it outputs the order from store.set to the console to make it easier to see what's happening.

http://jsbin.com/getudar/edit?html,js,console,output

When you drag an item from Group A to Group B it will call store.set on Group A without any changes. Nothing is called on Group B

If you rearrange Group B (with the new item in it) it will call store.set with the new item.

If you rearrange Group A, it will call store.set as if it still has all the original items.

It's a bit inconsistent right now, but I think it should by adding and removing items from the store when they're moved between them.

Is that correct?

All 4 comments

store - only to save/restore the order.
Everything else is not his area of responsibility.

I think this might be an issue.

I updated @graemegeorge's original fiddle so it outputs the order from store.set to the console to make it easier to see what's happening.

http://jsbin.com/getudar/edit?html,js,console,output

When you drag an item from Group A to Group B it will call store.set on Group A without any changes. Nothing is called on Group B

If you rearrange Group B (with the new item in it) it will call store.set with the new item.

If you rearrange Group A, it will call store.set as if it still has all the original items.

It's a bit inconsistent right now, but I think it should by adding and removing items from the store when they're moved between them.

Is that correct?

Hi,

here a working example, getting two list order to save.
http://jsbin.com/necabofika/1/edit?html,js,console,output

I change to 1.4.2 Sortable version.

I hope this help

In case anyone else comes across this and needs to solve it,
I managed to come up with a solution here which saves and restores across multiple list:

https://codesandbox.io/s/optimistic-dew-7mre4?file=/src/index.js

Not sure why it doesn't support storing position across different list by default, but oh well..

Was this page helpful?
0 / 5 - 0 ratings