Reputation: 1382
I can't figure out what the error in the console means when I run my jsfiddle.
And this is the beginning of the error:
jQuery.Deferred exception: Unable to process binding "foreach: function (){return items }" Message: Unable to process binding "value: function (){return itemNo }" Message: itemNo is not defined
anonymous/<.value@https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js line 68 > Function:1:58 a.d.value.init/m@https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js:102:301 z.Qc@https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js:51:391
That is all in yellow but there is a single red error at the bottom: ReferenceError: itemNo is not defined
. It bugs me that the console never gives relevant line numbers. I supposed with libraries, partial views, layouts, etc, it makes it difficult.
Upvotes: 1
Views: 60
Reputation: 3634
The error is saying that itemNo
dose not exist in your foreach context and that's because you are passing the entire array of json as string so you need to parse your json string.
Try :
ko.mapping.fromJS(JSON.parse(items),{},self.items)
.
Example : https://jsfiddle.net/rwa03vrb/4/
Upvotes: 1