Perhaps you should write
x.Name
instead of
x.getElementsByName('Name')
since I do not see where x should obtain this method from, as x is not an element of the document tree. But I am not an expert on this.
Ok, this works for me:
// My Model
function Customer(id, name, lastname) {
this.Id = ko.observable(id);
this.Name = ko.observable(name);
this.LastName = ko.observable(lastname);
}
// My ViewModel
ViewModel = (function () {
var customer = new Customer(1, "Thomas", "D")
var getName = ko.computed(function () {
return customer.Name ();
})
;
return {
getName: getName
};
})();
ko.applyBindings(ViewModel);
The getName in the return statement must be a function, not the result of a function. Probably the framework (which I do not know) calls the function (without arguments) in order to obtain the value.