Medium
Considering the following code used to define a template for an application, what can we say about this code?
<script id="bookTemplate" type="text/x-jQuery-tmpl">
<div>
<img src="BookPictures/${picture}"alt=""/>
<h2>${title}</h2>
price: ${formatPrice(price)}
</div>
</script>
<script type="text/javascript">
// Create an array of books
var books=[
{ title: 'ASP.NET 4 Unleashed', price: 37.79, picture: 'AspNet4Unleashed.jpg' },
{ title: 'ASP.NET MVC Unleashed', price: 44.99, picture: 'AspNetMvcUnleashed.jpg' },
{ title: 'ASP.NET KickStart', price: 4.0, picture: 'AspNetkickStart.jpg' },
{ title: 'ASP.NET MVC Unleashed iPhone', price: 44.99, picture: 'AspNetMvcUnleashedIPhone.jpg' }
];
// Display the books using the template
$('#bookTemplate').tmpl(books).appendTo('#bookContainer');
function formatPrice(price){
return '$'+ price.toFixed(2);
}
</script>
Author: InconnuStatus: PublishedQuestion passed 252 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
Similar QuestionsMore questions about jQuery
1
Which of these different propositions are correct regarding AJAX processing in jQuery?1
We want to develop a jQuery plug-in or simply define our own methods or properties on the object by augmentation. Which of these statements are correct?0
How to bind a click event to a div, p and b elements in jQuery.0
Use categories in event names in jQuery0
What is the `.ready()` method in jQuery?