Your observable use of the array, for example self.events.push(event); is correct (since the observable array implements push ), only your warnings are wrong.
The right challenges will be
alert(self.events().length) alert(self.events()[0].name());
Since you need to call the observable array as a function, like a normal ko.observable , to get the main value of the array itself.
However, you are currently adding the CalendarViewModel to the array to the whole because btnAddNewEvent is outside of your with binding, so the current context will be your main view model.
One way to solve it: just add self.event to the array, therefore:
self.addEvent = function() { self.events.push(self.event); alert(self.events().length) alert(self.events()[0].name()); }
But this can cause problems later when you want to add another element, because you end up referring to the same element, so the correct solution will copy the properties somewhere:
So, I would create a constructor function for your event class:
var Event = function(data) { var self = this; self.name = ko.observable(data.name()), self.adress = ko.observable(data.adress()), self.startTime = ko.observable(data.startTime()), self.endTime = ko.observable(data.endTime()) }
And click on the new event in addEvent
self.events.push(new Event(self.event));