I’m going to write an introductional blog post on KnockoutJS soon. In the meantime, check out the great introduction video of the creator Steve Sanderson.
The new features of version 2.0.0 are:
- Control flow bindings
You don’t need a template engine like jquery-tmpl any longer. Simply use the new control flow bindings if, ifnot, with, and foreach.
<ul data-bind="foreach: products"> <li> <strong data-bind="text: name"></strong> <em data-bind="if: manufacturer"> — made by <span data-bind="text: manufacturer.company"></span> </em> </li> </ul>
- Containerless control flow
You can now avoid using a container element for bindings like foreach by using the new comment-based control flow syntax.
<ul> <li><strong>Here is a static header item</strong></li> <!-- ko foreach: products --> <li> <em data-bind="text: name"></em> </li> </ul>
- Access to parent binding contexts
You can now access properties that exist at the upper levels of binding via the new pseudo-variables $data, $parent, $parents and $root.
- Cleaner event handling
There is now a cleaner, more declarative syntax for event handling bindings that does no longer require to write inline function literals.
- Binding providers
There is a new binding providers API to extend the default data binding mechanism. It acts as a general extensibility mechanism.
It is now possible to limit how often change events are fired (e.g. only one change event per 500ms). BTW, ko.dependentObservable has been renamed to ko.computed.
For a full list of all new features see Steve Sanderson’s blog entry.