Skip to content

Commit 0d47d40

Browse files
committed
Redo not_inline.html to get template via ajax.
1 parent 8251c5b commit 0d47d40

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

not_inline.html

+9-17
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515
{ Name: "Eyes Wide Shut", ReleaseYear: "1999", Director: "Stanley Kubrick" },
1616
{ Name: "The Inheritance", ReleaseYear: "1976", Director: "Mauro Bolognini" }
1717
];
18-
</script>
19-
20-
21-
<script id="summaryTemplate" src="template.html" type="text/x-jquery-tmpl"></script>
22-
23-
24-
<script>
25-
function renderList() {
26-
$( "#summaryTemplate" ).tmpl( movies ).appendTo( "#moviesList" );
27-
}
28-
</script>
29-
30-
31-
<script>
32-
$(function(){
33-
$('#showBtn').click(function(data){
34-
renderList();
18+
19+
$(function() {
20+
$.get('template.html', function(tmpl) {
21+
var output = $.tmpl(tmpl, movies);
22+
23+
$('#showBtn').click(function(e) {
24+
e.preventDefault();
25+
output.appendTo('#moviesList');
26+
});
3527
});
3628
});
3729
</script>

template.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<script id="summaryTemplate" type="text/x-jquery-tmpl">
2-
<tr> <td>${Name}</td> <td>${ReleaseYear}</td> <td>${Director}</td> </tr>
3-
</script>
1+
<tr> <td>${Name}</td> <td>${ReleaseYear}</td> <td>${Director}</td> </tr>

0 commit comments

Comments
 (0)