I am trying to see if I can assign a JavaScript variable to the value of a value of a KO Observable.
The reason for this is I want to assign it to a jquery module, as a property.
I know I can do:
var viewModel = { firstName : ko.observable("Bert"), lastName : ko.observable("Smith"), pets : ko.observableArray(["Cat", "Dog", "Fish"]), type : "Customer" }; viewModel.hasALotOfPets = ko.computed(function() { return this.pets().length > 2 }, viewModel) var jsonData = ko.toJSON(viewModel); But, what if I don't want everything that is in the view model? Can i just only select n number of items?