Thursday, September 26, 2013

Knockout.js Gotchas


  1. Knockout's observableArray dependency tracking breaks if you bind with a call to sort,reverse, etc.
    1. Therefore don't do things like data-bind="foreach items.sort()", you instead bind normally with sortedItems() and then create a computed property sortedItems that sorts items. Be careful though this technique will sort items in place and not just the new computed property sortedItems.
    2. http://stackoverflow.com/questions/18729643/ko-observablearray-update-breaks-when-binding-with-sort

No comments:

Post a Comment