Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created March 3, 2013 14:10
Show Gist options
  • Save EdwardIII/5076249 to your computer and use it in GitHub Desktop.
Save EdwardIII/5076249 to your computer and use it in GitHub Desktop.
var GuestView = function(){
this.guestlist = ko.observableArray(ko.utils.arrayMap(tickets, function(ticket) {
return {
// How do i sync up guests and tickets, and ensure that when
// the num_of_guests increases, new guest input fields are created?
}))
}
var TicketView = function(){
this.tickets = ko.observableArray()
};
tickets = [
{ name: 'With champers', price: '9.99', num_of_guests: ko.observable(0), guests: ko.observable(new Guests())},
{ name: 'Meal only', price: '6.99', num_of_guests: ko.observable(0), guests: ko.observable(new Guests())}
]
ko.applyBindings(new TicketView(), document.getElementById('tickets'));
ko.applyBindings(new GuestView(), document.getElementById('guestlist'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment