KnockOutJS – Multiple ViewModels in a single View

Knockout now supports multiple model binding. The ko.applyBindings() method takes an optional parameter – the element and its descendants to which the binding will be activated.

For example:

ko.applyBindings(myViewModel, document.getElementById('someElementId'))

This restricts the activation to the element with ID someElementId and its descendants.

See documentation for more details.

Leave a Comment