I am currently experimenting with a basic knockout script (still in the learning process).
$.getJSON(clientUrl + "/list/" + 1, function (data) {
var viewModel = {
clients: ko.observableArray(data)
};
ko.applyBindings(viewModel);
});
The initial argument 'lucidServer.getClients(1)' triggers an ajax request:
var getClients = function (id) {
return $.ajax(clientUrl + "/list/" + id)
};
Although I am receiving the json response, it appears to not bind correctly to the template. Here is the json data:
0: {iD:1, userId:1, name:CompanySoft, LLC.,…}
1: {iD:2, userId:1, name:Widget Factory,…}
2: {iD:3, userId:1, name:Jim's Consulting,…}
The template code is as follows:
<div id="clientListOutput">
<ul "template: { foreach: clients }">
<li><span data-bind"text: name"></span></li>
</ul>
</div>