Monday, 9 September 2013

knockout.js complex obeservable?

knockout.js complex obeservable?

I have the following model
var ViewModel = function(){
var self = this;
self.appointment = {
title: ko.observable(),
description: ko.observable(),
time: ko.observable(),
address1: ko.observable(),
address2: ko.observable(),
phone: ko.observable(),
email: ko.observable(),
}
);
And then mapped by json data, which will produce an observableArray of
appointment items, called appointment_set
I have a view which binds to the appointment element of the model, but
when I set the appointment element with an element from the
observableArray, the view won't update with the values, see below:
viewmodel.appointment = viemodel.appointment_set()[0];
I think it's because appointmentitself is not observable, how do I fix this?

No comments:

Post a Comment