- <script id="movieTemplate" type="text/x-jquery-tmpl">
- {{tmpl($item.data, $item) "#titleTemplate"}}
- <tr class="detail"><td>Director: ${$item.embolden(Director)}</td></tr>
- </script>
- <script id="titleTemplate" type="text/x-jquery-tmpl">
- <tr class="title"><td>${$item.embolden($item.data.Name)}</td></tr>
- </script>
- <table><tbody id="movieList"></tbody></table>
- var formatHelpers = {
- embolden: function(i) {
- return "*" + i + "*";
- }
- };
- var movies = [
- { Name: "The Red Violin", Director: "François Girard" },
- { Name: "Eyes Wide Shut", Director: "Stanley Kubrick" },
- { Name: "The Inheritance", Director: "Mauro Bolognini" }
- ];
- /* Render the template with the movies data */
- $( "#movieTemplate").tmpl(movies, formatHelpers).appendTo("#movieList");
转载请注明:谷谷点程序 » jquery tmpl下加载函数的使用方法