I have two sortable lists which hold work orders. The second list is a Route
while the first is just a list of all the work orders that haven't been added to the Route
list. The idea is that the user drags work orders into the Route
in a specific order, rearranging the work orders to create a route that the employee will follow.
My problem is with managing the position of new work orders dragged onto the Route
list. Is there an easy way to deal with updating the positions of all of the list items (on the database side of things via ajax calls) as new items are being added?
A bit more info for clarity...
When the Route
list is empty (no work orders added yet) it is simple - user drags new work order onto empty list, ajax call made to save the details (on the underlying records on the server) of both the Route
object and the Route Item
just added.
When the user drags the second work order into the Route
list I want to determine if the new work order will become first in the list, or second, then update all the information (server side) accordingly for all items in the list. Things get really complicated when I want to add a new work order to a Route
that already has like 30 work orders.
Is there a simple way to do this or is it just a matter of coding up a decent amount of jQuery and backend functions to manage this? I have been hunting around the net for solutions but can't find anything all that definitive.