Form Repeat sortable support for drag/drop events

The sort option of a form repeat is great, but it could be enhanced by supporting the events that sortable provides, such as onEnd which triggers an event every time the user finishes dragging an element to a new position. I deal with this today, by simply turning off the sort option, and manually setting it up in js, but having in the UI would obviously be much better.

The use case is that when adding a new item into a form repeat, I need to prefill values on the inputs, so I use a data store as the source for the form repeat and add new entries as needed – works great. But if the items are re-ordered, and then a new item is added, it will naturally revert to the original sort. So if I use an onEnd event to keep all of that in order.

@mebeingken, do you have an example of js code you used to grab the onEnd event? I’ve tried to using the sortableJs docs but nothing I’ve tried has worked.

Have a look at this @ben’s video here:
sorting - YouTube
after the sorting tutorial, at about 14’:30’’

1 Like

@famousmag thank you! Exactly what I was looking for and much easier than what I was trying. You rock @ben!

-Twitch

1 Like

Another example here

2 Likes