Using a Nested Template

One reason to create an external template is so that you can create nested Repeaters. Imagine, for example, that you want to create an evil organization chart used by a company that specializes in producing evil (see Figure 7.5).

Image

FIGURE 7.5 An evil org chart

The JavaScript file in Listing 7.10 contains the data for the org chart. Notice that the data follows a pattern. The data is a list of employees. Each employee can have a minions property that represents another list of employees. An org chart can be arbitrarily deep.

LISTING 7.10 Using Nested Repeaters (repeaterNested\repeaterNested.js)

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.