Does KnockoutJS have a feature whereas I could take something like:
var myArray = ko.observableArray([
{ name: \"Jimmy\", type: \"Friend\" },
I have simplified RP Niemeyer's version in jsfiddle to do the same without using the distinct function. Please refer here: jsfiddle
-
var Person = function(name, type) {
this.name = ko.observable(name);
this.type = ko.observable(type);
}
var ViewModel = function() {
var self = this;
this.choices = ["Friend", "Enemy", "Other" ];
this.people = ko.observableArray([
new Person("Jimmy", "Friend"),
new Person("George", "Friend"),
new Person("Zippy", "Enemy")
]);
this.addPerson = function() {
self.people.push(new Person("new", "Other"));
};
this.removePerson = function(person) {
self.people.remove(person);
};
};
ko.applyBindings(new ViewModel());
Thanks Niemeyer.