Binding true / false to radio buttons in Knockout JS

I know this is an old thread, but I was having the same problem and found out a much better solution that was probably added to knockout after this question was officially answered, so I’ll just leave it for people with the same problem. Currently there is no need for extenders, custom binding handlers or … Read more

Map JSON data to Knockout observableArray with specific view model type

Check this http://jsfiddle.net/pTEbA/268/ Object.prototype.getName = function() { var funcNameRegex = /function (.{1,})\(/; var results = (funcNameRegex).exec((this).constructor.toString()); return (results && results.length > 1) ? results[1] : “”; }; function StateViewModel(data){ this.name = ko.observable(); ko.mapping.fromJS(data, mapping, this); } function CityViewModel(data) { this.name = ko.observable(); ko.mapping.fromJS(data, mapping, this); } function StreetViewModel(data) { this.name = ko.observable(); ko.mapping.fromJS(data, mapping, this); … Read more

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.