-
Notifications
You must be signed in to change notification settings - Fork 0
/
templating.js
38 lines (30 loc) · 1.22 KB
/
templating.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$(function () {
"use strict";
var App = {
init:function () {
var that = this;
this.movies = [
{ Name:"The Red Violin", ReleaseYear:"1998" },
{ Name:"Eyes Wide Shut", ReleaseYear:"1999" },
{ Name:"The Inheritance", ReleaseYear:"1976" }
];
this.markup = "<li class='list-item'>${Name} (${ReleaseYear})</li>";
$.template("movieTemplate", this.markup);
$("#AddMovie").click(function () {
this.newMovie = $("#newMovie").val();
this.releaseDate = $("#releaseDate").val();
$("#movieList").empty();
that.movies.push({ Name:this.newMovie, ReleaseYear:this.releaseDate });
$("#newMovie").val("");
$("#releaseDate").val("");
that.render();
}
);
this.render();
},
render:function () {
$.tmpl("movieTemplate", this.movies).appendTo($("#movieList"));
}
};
window.MovieApp = App.init();
});