-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery-handlebars-done.html
More file actions
145 lines (125 loc) · 4.37 KB
/
jquery-handlebars-done.html
File metadata and controls
145 lines (125 loc) · 4.37 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link href="/js/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="/js/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" />
<link href="./style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-3">
<div style="padding-top:20px;">
<a href="/"><img src="./bower.png" alt="bower logo" width="100"/></a>
</div>
</div>
<div class="col-md-9">
<div class="txt_right">
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default">회원가입</button>
<button type="button" class="btn btn-default">로그인</button>
<button type="button" class="btn btn-default">패밀리사이트</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-2">
<div> </div>
<div> </div>
<div>
<ul>
<li>메뉴1</li>
<li>메뉴2</li>
<li>메뉴3</li>
<li>메뉴4</li>
</ul>
</div>
</div>
<div class="col-md-10">
<h1>테이블 샘플입니다</h1>
<div id="displayDiv"></div>
<div style="width:400px;margin:0 auto;">
<nav aria-label="Page navigation">
<ul class="pagination">
<li><a href="#" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#" aria-label="Next"><span aria-hidden="true">»</span></a>
</li>
</ul>
</nav>
</div>
</div>
</div><!-- row -->
<div class="row">
<hr>
<div class="txt_center">
footer
</div>
</div>
</div> <!-- container -->
<div class="container">
</div>
<script src="/js/jquery/dist/jquery.min.js"></script>
<script src="/js/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="js/handlebars/handlebars.min.js"></script>
<script>
//사용자 정의 헬퍼
Handlebars.registerHelper("prettifyDate", function (timeValue) {
var objDate = new Date(timeValue);
var year = objDate.getFullYear();
var month = objDate.getMonth() + 1;
var date = objDate.getDate();
return year + "-" + month + "-" + date;
});
var data = [
{ num: 1, title: "제목", userName: "홍길동", userEmail: "sample@daum.net", regDate: new Date(), viewCount: 1 },
{ num: 1, title: "제목", userName: "홍길동", userEmail: "sample@daum.net", regDate: new Date(), viewCount: 1 },
{ num: 1, title: "제목", userName: "홍길동", userEmail: "sample@daum.net", regDate: new Date(), viewCount: 1 },
{ num: 1, title: "제목", userName: "홍길동", userEmail: "sample@daum.net", regDate: new Date(), viewCount: 1 },
{ num: 1, title: "제목", userName: "홍길동", userEmail: "sample@daum.net", regDate: new Date(), viewCount: 1 },
];
$(document).ready(function () {
var source = $("#template").html();
var template = Handlebars.compile(source);
$("#displayDiv").html(template(data));
});
</script>
<script id="template" type="text/x-handlebars-template">
<table class="table table-straped">
<colgroup>
<col width="10%" />
<col width="40%" />
<col width="20%" />
<col width="20%" />
<col width="10%" />
</colgroup>
<thead>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성일</th>
<th>조횟수</th>
</thead>
<tbody>
{{#each .}}
<tr>
<td>{{num}}</td>
<td>{{title}}</td>
<td><a href="mailto:{{userEmail}}">{{userName}}</a></td>
<td>{{prettifyDate regDate}}</td>
<td>{{viewCount}}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>
</body>
</html>