public
Description: PURE Unobtrusive Rendering Engine for HTML
Home | Edit | New

Iteration

This example is about iteration.
For each entry we get in the JSON we want a new row in the table

 

The HTML:

<table class="players">
  <thead>
    <tr><th class="player">Player</th></tr>
  </thead>
  <tbody>
    <tr class="context">
      <td class="player context">Chloe</td>
    </tr>
  </tbody>
</table>

 

The JSON data:

var json = 
[ "Alice Keasler", 
  "Charles LeGrand", 
  "Gary Bitemning", 
  "Helen Moren" ]

 

The Javascript to do this action (here with jQuery):

$( 'table.players' ).autoRender( json );

 

Note:

Here the special keword ‘context’ is used when we want to access the root property of the JSON.
It is described in details at the ‘context’ notation

Last edited by pure, Fri Jan 09 05:51:15 -0800 2009
Home | Edit | New
Versions: