<html>
<head>
<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>
</head>
<body>
<script id="movieTemplate" type="text/x-jquery-tmpl">
{{each items}}
<li>
Title: ${Name}.
{{each Languages}}
${$index + 1}: <em>${$value}. </em>
{{/each}}
</li>
{{/each}}
</script>
<ul id="movieList"></ul>
<script>
var movies = [
{ Name: "Meet Joe Black", Languages: ["French"] },
{ Name: "The Mighty", Languages: [] },
{ Name: "City Hunter", Languages: ["Mandarin", "Cantonese"] }
];
var data = {items: movies}
/* Render the template with the movies data */
$( "#movieTemplate" ).tmpl( data )
.appendTo( "#movieList" );
/* Хочу получить инфу только о ПЕРВОМ элементе. */
console.log($("#movieList li:first-child").tmplItem());
</script>
</body>
</html> |