Ko Updating an Array

by Richard Hunter

HTML

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js&quot;"></script>
<ul data-bind="foreach: names">
    <li data-bind="text: name"></li>
</ul>

<button data-bind="click: update">update Array</button>

JavaScript

self = {};

self.names = ko.observableArray([
    { name : "Richard"},
    { name : "Bob" },
    { name : "Alice" }
]);

self.update = function () {

    self.names([
        { name : "Dave" },
        { name : "Amy" }
    
    
    
    ]);


}

ko.applyBindings(self);