I have a problem to map my json object returned by a WCF. wcf return a list of PaidPeople class, and jSon return look like
[Object { __type="PaidPeople:#model", Amount=110, Attendee=1, more...}, more...]
I also JSON.stringify the return object and i get an array of
[
{"__type":"PaidPeople:#model","Amount":110,"Attendee":1,"CashPay":1,"DtPaid":"/Date(1338102000000-0700)/","Name":"John Doe"}, more
]
my problem is mapping it to my view
here is the code
var PayinyVM = {};
$.getJSON('/service/PaidService.svc/PaidList', function (data) {
var tmp = JSON.stringify(data.d);
PayinyVM.model = ko.mapping.fromJSON(tmp);
ko.applyBindings(PayinyVM);
}); //getJSON
and HTML is looking like:
<div data-bind="foreach: ????">
<h3 data-bind="text: Name">
</h3>
<p>
Name: <span data-bind="text: Name"></span>
</p>
</div>
I just started coding with knockout after long time jquery code, and really like it, but I miss a lot of practice. Any help would be greatly appreciated
Try to use following code (
modelinstead of????):