Search code examples
knockout.jsbreezedurandalknockout-es5-plugin

How to use Knockout-ES5 plugin with Breeze and Durandal


How can I use steve's Knockout-ES5-Plugin (http://blog.stevensanderson.com/2013/05/20/knockout-es5-a-plugin-to-simplify-your-syntax/) with Breeze and Durandaljs?

Thanks a lot!


Solution

  • The selected answer to this post takes the approach of:

    • using Breeze's built in BackingStore modelLibrary (instead off the Knockout modelLibrary)
    • making entities observable "as required" using the ES5 plugin by effectively calling ko.track(entity._backingStore) when a user indicates they want to edit a record.

    This has the advantage of being much lighter for long lists of entities by not making them observable until they need to be. The ES5 plugin adds the benefit that the bindings in HTML don't need to change between the non-observable entities and the observable ones (as the brackets are not required).

    If you required all entities to be "ES5" observable by default then you'd probably be best to write a custom modelLibrary adapter - take a look in the Breeze debug file (or source) to see the three built in adapters: backingStore, backbone, and ko as examples.