coderenaissance / knockout.viewmodel

The knockout viewmodel plugin is the fastest, smallest, cleanest, most flexible way to create a knockout viewmodel.
http://coderenaissance.github.com/knockout.viewmodel
106 stars 28 forks source link

Sorting ObservableArray #63

Closed codekhol closed 9 years ago

codekhol commented 9 years ago

Hi I have a problem in sorting an observable array in my model. The problem is I have different models and with each model I dont know where my observable array is. I added a "extend" processing option so it is applied to any property name called "m" and "m" is my observable array I want to sort. Depending on the model I pass "m" could be in a different path. Sorting works only the first time when initialising, but with new incoming updates (from signalr) my observable array does not sort

var mappingOptions = {
            extend: {
                "m": function (markets) {
                    markets.sort(viewModel.marketSorter);
                    return markets;
                }
};

I don't know what processing option (or else) I can use to sort the array when data is updated.