\n\n```","suggestedAnswer":[{"@type":"Answer","text":"The choice of the MIME type of the template(`text/x-jQuery-tmpl`) in the HTML code is chosen so that it is not recognized by the html parser of the browser so that it is not interpreted at execution."},{"@type":"Answer","text":"The choice of container for the template must be included in atag"},{"@type":"Answer","text":"Any variable to be provided by the template must be enclosed in braces preceded by the javascript symbol $. Example: ${title}"},{"@type":"Answer","text":"The proposed code is not functional, it contains inaccuracies."}],"acceptedAnswer":[{"@type":"Answer","text":"The choice of the MIME type of the template(`text/x-jQuery-tmpl`) in the HTML code is chosen so that it is not recognized by the html parser of the browser so that it is not interpreted at execution."},{"@type":"Answer","text":"Any variable to be provided by the template must be enclosed in braces preceded by the javascript symbol $. Example: ${title}"}]}}

Question from the jQuery test

Given a template for an application, write a description of the template.

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 260 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!