knockoutJS mapping template nested arrays in jsfid

2019-08-10 08:57发布

I have this fiddle:

http://jsfiddle.net/gY2JV/63/

How come the data is not showing?

标签: knockout.js
1条回答
太酷不给撩
2楼-- · 2019-08-10 09:20

There are several things that should be changed:

vm = new DocsVM({
    MyDocs: ko.mapping.fromJS(jsonData)
});

Why do the mapping here when DocsVM does another mapping?

vm = new DocsVM(jsonData);

Template names need to be in quotation marks:

template: {name: TrTemplate

=>

template: {name: 'TrTemplate'

This is not a valid binding:

<a data-bind="html:  'DisplayName

=>

<a data-bind="text: DisplayName

Another note: Why do you bind the event handler for the button using jQuery? Use knockout for that, for the sake of consistency.

http://jsfiddle.net/gY2JV/64/

查看更多
登录 后发表回答