O'Reilly logo

KnockoutJS Web Development by John Farrar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enhanced collection handling

In our first segment, native templates, we focused on single sets of data. In JavaScript, we often have collections of data stored in arrays. We will be including an example here to show how to use templates stored in arrays.

We can copy the data from our last example page to this page. We will be using more of the structure this time around. We will start by focusing on the speakers. This array contains structured items for each speaker. The code section of our script tag should look like this:

vm = ko.mapping.fromJS(mySeminar);
ko.applyBindings( vm );

If you think this looks basically the same as the last example of code, you are right. It will change soon, but we are looking to make a point here. Arrays and non-arrays ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required