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

I need a method(like onMove) to execute after two items exchange their position,can you implement it? #1409

Closed
zhao943018529 opened this issue Dec 19, 2018 · 4 comments

Comments

@zhao943018529
Copy link

zhao943018529 commented Dec 19, 2018

Hi,
I want to update the sort items rank number when i'm dragging item to resort them.But I found the onMove function not fit with this case.

@owen-m1
Copy link
Member

owen-m1 commented Dec 19, 2018

@zhao943018529 I can add an onChange event that will fire when the element changes position, and it will give the new index. This will also solve #1323

@drannex42
Copy link

@owen-m1 that would be fantastic - especially when dealing with a position based index sort system.

Would this mean natively it would automatically update the index for all items when even one changes position?

@owen-m1
Copy link
Member

owen-m1 commented Jan 3, 2019

@drannex42 The indexes for the other items are never given in the events, but you can calculate it yourself using Sortable.utils.index(element, '>*');.

@owen-m1
Copy link
Member

owen-m1 commented Jan 15, 2019

As of 1.8.0, use the onChange event.

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

3 participants