Closed marselmustafin closed 3 years ago
Hi @marselmustafin, the update is done at the database level in one statement so there’s no inherent way of knowing. In terms of the shuffling that occurs anyway.
You can add an after
callback that also then checks if the position column is dirty and react to that.
@brendon thanks for the suggestion!
We've tried it in our app, but the issue is that after_update
is called twice because first the current item's position is set to bottom_position_in_list + 2
and then set to the correct position.
The solution we're working on now is to first check in after_update
if self.position
is bottom_position_in_list + 2
. If it is, skip after_update
callback and wait until the callback is called the second time.
I hope that works out :) It sounds a bit tricky!
I'm very happy to look at a PR if you want to implement this in acts_as_list
. Just bear in mind that it'll have to make sense for other users using the project :D
I need to some callback be called for all records in list that changed position? Is it possible somehow?