knockoutJS mapping template nested arrays in jsfid

2019-08-10 09:15发布

问题:

I have this fiddle:

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

How come the data is not showing?

回答1:

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/



标签: knockout.js