1

When I call ko.mapping.fromJS(model) it creates a blank array. I am trying to create an observable array with observable properties. The initial model variable object as a string looks like this "[{"Key":"test","Speeches":[{"Text":"test"}]}]". Why is the fromJS method returning an empty array [] ?

1 Answer 1

2

If your model is in JSON (string representation), then you need to use ko.mapping.fromJSON(model).

Otherwise, it should work fine. I know that console.log on an observableArray in Chrome shows [], so maybe the data is there.

Here is a sample that shows both ways and that the data is valid: http://jsfiddle.net/rniemeyer/PBhG3/

Sign up to request clarification or add additional context in comments.

1 Comment

You maybe right then. We went a different route at the moment but I will mark it as correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.