Bindings enhancements
- The css binding accepts multiple classes in a string and dynamic class names.
- The text binding can be used in virtual elements: <!--ko text: myValue--><!--/ko-->
- For the options binding, it will skip destroyed items (unless optionsIncludeDestroyed is passed as truthy), optionsValue can accept a function just like optionsText, and optionsCaption can be an observable.
- The with binding will bind to the original child DOM elements when its initial value is truthy, and keep a copy of the elements as a template.
- The if and ifnot bindings will bind to the original child DOM elements when the initial value is truthy for if or falsy for ifnot. Additionally, they will only re-render the content when the truthiness of the value changes.
- The attr binding handles the name attribute properly in older versions of IE.
Computed observable and binding dependency enhancements
- Observables (including computed) include a peek function for access within a computed without adding a dependency.
- observableArray mutation functions no longer cause a dependency within a computed.
- Writes to writeable computeds can now be chained like observables.
- Computed observables now have an isActive function that indicates that the computed has dependencies (can be triggered again).
foreach and template enhancements
- change (normal manual subscription) and beforeChange callbacks no longer create dependencies.
- When a function is used for the template name, it now receives the binding context as the second argument.
- The foreach functionality now does its best to understand items that were moved and move their content rather than re-render them.
- beforeMove and afterMove callbacks can now be configured when using foreach functionality.
- The foreach and template bindings now accept an as option to give $data an alias.
Other binding enhancements
- The afterRender, beforeRemove, afterAdd, beforeMove, and afterMove callbacks will no longer cause dependencies.
- The ko object is now available from within bindings, even if ko is not global, such as when used with an AMD loader.
- Can access the current element in a binding using the $element variable.
- Can access the current context directly in a binding using the $context variable.
Yay, it's released! The 2.2.0 Release Candidate build proved pretty solid (thanks to everyone who tried it), the docs are all updated, the specs are 100% passing on all supported browsers, and so this new release is final as of today.
Yay, it's released! The 2.2.0 Release Candidate build proved pretty solid (thanks to everyone who tried it), the docs are all updated, the specs are 100% passing on all supported browsers, and so this new release is final as of today.