Skip to content

Instantly share code, notes, and snippets.

@pure
Created November 29, 2011 11:39
Show Gist options
  • Save pure/1404516 to your computer and use it in GitHub Desktop.
Save pure/1404516 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://github.com/pure/pure/raw/master/libs/pure.js"></script>
</head>
<body>
<input type="button" onclick="addRow()" value="add" />
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<script>
var data = {
rows:[
{nb:0},
{nb:1}
]
},
dirTR = {
td:'row.nb'
},
dir = {
tr:{
'row<-rows':dirTR
}
};
var trCompiled = $('tr').compile(dirTR);
$('table').render(data, dir);
function addRow(){
var tr = $('tbody').append('<tr></tr>').find('tr:last');
data.rows.push({nb:data.rows.length});
tr.render({row:data.rows[data.rows.length - 1]}, trCompiled);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment