I have a problem that is summarized in this simple example: http://jsfiddle.net/2wFHX/
I need to set the ‘priority’ and ‘list’ observables to be the correct values depending upon which list it is moved into or reordered within.
For example, if all the tasks are in ‘List 1’ in the order A,B,C the priorities in the viewmodel observableArray should be set accordingly (0,1,2).
Note that the lists are deliberately bound using a function. I think this is where the knockout sortable extension is causing problems. Ideally I’d like to keep all my tasks in a single collection as it will make dealing with web services slightly easier later on, but I don’t think the extension supports using a function as a data source?
I’ve reworked my code to work from observableArrays instead of the function, and also added a subscriber to update the indexes when there are any changes.
For anyone who’s interested here is my reindex function: