I’m trying to do dynamic sortable list with link “Add Destination” such as Google – Get directions screenshot below. Big problem is that in sorted inputs sequence IDs should be maintained and the contents changed after draging. Input is able to drag before “A” and last, remove by “x” right field. Adding additional waypoints, judging by this: directions-waypoints tutorial should be get as array in JavaScript, waypoints is always middle “A” and last fields, input point “A” always name eg. “from”, last “goal”. I would like to do latter fields filling by autosuggestion from Google places. I was looking everywhere for some solution but its is too different.
EDIT: I collected everything from different sources end I got in result not quite good code: jsfiddle.net/fasE5/5/

Here is a complete working example: http://jsfiddle.net/fasE5/19/
The HTML I came up with:
And the CSS, to make it look a little more pretty:
To keep the right order of the
input‘snameattribute and the order letters (A, B, C…), we call toRecalculateOrderon sort update and when removing an destination.To prevent from removing the last 2 destinations, we add an
isOnlyTwoclass to the#sortablediv when there is only 2 destinaitons left. Which thanks to our CSS hides theremove_input.For the autocomplete we need GoogleMaps API
Which provides us an
new google.maps.places.Autocomplete(input)to add google’s autocomplete functionality.