JSFiddle - React, Tailwind, and code Playground

by dvdrom000

HTML

<span data-bind="text: customerOverview().contacts().length"></span>

<button data-bind="click: customerOverview().getCustomerContacts">Get contacts</button>

JavaScript

function CustomerOverview() {
    var self = this;

    self.contacts = ko.observableArray([]);

    self.getCustomerContacts = function () {
        self.contacts.push(1);
        self.contacts.push(2);
        self.contacts.push(3);
    };
};

function CustomerCentral() {

    var self = this;
    // Is this a correct way. Am I breaking something with this?
    self.customerOverview = ko.observable(new CustomerOverview());
};

var vm = new CustomerCentral();
ko.applyBindings(vm);