Browse Source

Added zepto example

Maurits van der Schee 8 years ago
parent
commit
c67bbaf46b
1 changed files with 15 additions and 15 deletions
  1. 15
    15
      examples/client_zepto.html

+ 15
- 15
examples/client_zepto.html View File

@@ -2,6 +2,20 @@
2 2
 <head>
3 3
 <script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js"></script>
4 4
 <script src="../lib/php_crud_api_transform.js"></script>
5
+<script id="PostListTemplate" type="text/html">
6
+	<ul>
7
+		<li>
8
+			<span class="id"></span>, <span class="content"></span>
9
+			<a href="javascript:void(0)" class="edit">edit</a>
10
+			<a href="javascript:void(0)" class="delete">del</a>
11
+		</li>
12
+		<li>
13
+			<form>
14
+				<input name="content"/>
15
+			</form>
16
+		</li>
17
+	</ul>
18
+</script>
5 19
 <script>
6 20
 function PostList(element,template) {
7 21
 	var self = this;
@@ -29,7 +43,7 @@ function PostList(element,template) {
29 43
 	};
30 44
 	self.render = function(data) {
31 45
 		data = php_crud_api_transform(data);
32
-		$(element).html($(template).find('ul').html());
46
+		$(element).html($(template).html());
33 47
 		var item = $(element).find('li').first().remove();
34 48
 		for (var i=0;i<data.posts.length; i++) {
35 49
 			var clone = item.clone();
@@ -55,20 +69,6 @@ $(function(){ new PostList('#PostListDiv','#PostListTemplate'); });
55 69
 </script>
56 70
 </head>
57 71
 <body>
58
-<div id="PostListTemplate" style="display:none;">
59
-	<ul>
60
-		<li>
61
-			<span class="id"></span>, <span class="content"></span>
62
-			<a href="javascript:void(0)" class="edit">edit</a>
63
-			<a href="javascript:void(0)" class="delete">del</a>
64
-		</li>
65
-		<li>
66
-			<form>
67
-				<input name="content"/>
68
-			</form>
69
-		</li>
70
-	</ul>
71
-</div>
72 72
 <div id="PostListDiv">
73 73
 	<span>Loading...</span>
74 74
 </div>

Loading…
Cancel
Save