Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (37 sloc) 1.41 KB
<!DOCTYPE html>
<html>
<head>
<style>
table { border-collapse:collapse; margin:8px; background-color:#f8f8f8; }
table td { height:30px; width:100px; border:1px solid blue; padding:3px; }
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script>
var movies = [
{ Name: "The Red Violin", ReleaseYear: "1998", Director: "Françs Girard" },
{ Name: "Eyes Wide Shut", ReleaseYear: "1999", Director: "Stanley Kubrick" },
{ Name: "The Inheritance", ReleaseYear: "1976", Director: "Mauro Bolognini" }
];
</script>
<script id="summaryTemplate" type="text/x-jquery-tmpl">
<tr> <td>${Name}</td> <td>${ReleaseYear}</td> <td>${Director}</td> </tr>
</script>
<script>
function renderList() {
$( "#summaryTemplate" ).tmpl( movies ).appendTo( "#moviesList" );
}
</script>
<script>
$(function(){
$('#showBtn').click(function(data){
renderList();
});
});
</script>
</head>
<body>
<button id="showBtn">Show movies</button><br/>
<table><tbody id="moviesList"></tbody></table>
</body>
</html>