I’m really struggling to sort a ko.observableArray. I’ve been searching for solutions for the past hour, and I’m pretty convinced I’m doing it by the book.
Basically the problem seems to come from the fact that the array of elements doesn’t actually exist at sort time. Each item is represented by a function which I assume allows KnockoutJS to listen for mutations…but it’s not helping me much 🙂
Link to JSfiddle | http://jsfiddle.net/farina/W7HJP/
Check out my fiddle and click the sort link. As you can see you’ll get a bunch of NaN values instead of actual sorting.
Any help would be greatly appreciated!!
When you access an observable’s value, you need call it as a function with zero arguments.
So:
So, in your sort, you would do:
http://jsfiddle.net/rniemeyer/W7HJP/10/