I am learning Knockout and cannot get Knockout.mapping.fromJS to work. Here is my code:
$.getJSON("data/status.json", function(data) {
var members = ko.mapping.fromJS(data);
});
ko.applyBindings(members);
I am using a template. Here is the template:
<script type="text/html" id="membersTemplate">
<li data-bind="text: members.dname"></li>
</script>
And the markup...
<div id="members">
<h2>Members</h2>
<ul data-bind="template: {name: 'membersTemplate', foreach: members}"></ul>
</div>
The JSON data loads correctly, but the "members" object is "undefined." (Members.dname is one object property among many.)
Can anyone tell me what I'm doing wrong? Thanks in advance!