I am reading and trying to understand an example jQuery template.
<script id="movieTemplate" type="text/x-jquery-tmpl"> {{tmpl "titleTemplate"}} <tr class="detail"><td>Director: ${Director}</td></tr> </script> <table><tbody id="movieList"></tbody></table> <script> var movies = [ { Name: "The Red Violin", Director: "François Girard" ,Producer : "ssss" }, { Name: "Eyes Wide Shut", Director: "Stanley Kubrick" }, { Name: "The Inheritance", Director: "Mauro Bolognini" } ]; $.template( "titleTemplate", "<tr class='title'><td>${Name}</td></tr>" ); $( "#movieTemplate" ).tmpl( movies ).appendTo( "#movieList" ); </script>
In this sample program, I cannot understand about:
/ * Convert the markup string to a named template using the {{tmpl}} tag * /
when we call: $ ("#movieTemplate") .tmpl (movies) calls the template so that we call the template function with input films and add it to the list of films
if i delete the code
$.template( "titleTemplate", "<tr class='title'><td>${Name}</td></tr>" );
he does not work. Could you explain why we need it and what it does here, for example: / * Convert the markup string to a named template, that’s all.
I tried to read and realized that I was not getting this clarified
The learningner
source share