1

Can someone tell me why this is not working?

function Event() {
    self.EventName = ko.observable();
    self.EventTypeID = ko.observable();
    self.EventTypeName = ko.observable();
    self.DepartmentID = ko.observable();
    self.DepartmentName = ko.observable();
    self.EventDescription = ko.observable();
    self.EventDate = ko.observable();
    self.EventItems = ko.observableArray([]);
    self.MembersAttended = ko.observableArray();
};

self.EventToAdd = new Event();
self.EventToAdd.EventName = 'test';
self.EventToAdd.EventItems.push(new EventItem(4));

I am getting that push is undefined.

Thanks!

1 Answer 1

1

Add var self = this; as the first line in your Event method. Without it, you are accidentally adding all of the properties to your container object instead of to your Event object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.