Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: b3db791b0d
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (55 sloc) 1.344 kB
<html>
<head>
<title>PURE Unobtrusive Rendering Engine - Recursion</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<ul class="treeItem">
<li>
<a class="name" href="javascript:">name</a>
<div class="children"></div>
</li>
</ul>
<script>
var data = {
children: [{
name: 'Europe',
children: [{
name: 'Belgium',
children: [{
name: 'Brussels',
children:null},{
name: 'Namur'},{
name: 'Antwerpen'}]},{
name: 'Germany'},{
name: 'UK'}]},{
name: 'America',
children: [{
name: 'US',
children: [{
name: 'Alabama'},{
name: 'Georgia'}]},{
name: 'Canada'},{
name: 'Argentina'}]},{
name: 'Asia'},{
name: 'Africa'},{
name: 'Antarctica'}
]
};
var directive = {
'li': {
'child <- children': {
'a': 'child.name',
'a@onclick':'alert(\'#{child.name}\');',
'div.children': function(ctxt){
return ctxt.child.item.children ? rfn(ctxt.child.item):'';
}
}
}
};
var rfn = $('ul').compile( directive );
$('ul').render( data, rfn );
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.