|
@@ -24,22 +24,22 @@ function PostList(element,template) {
|
24
|
24
|
var li = $(this).parent('li');
|
25
|
25
|
var id = li.find('span.id').text();
|
26
|
26
|
var content = li.find('span.content').text();
|
27
|
|
- content = prompt('Value',content);
|
|
27
|
+ content = prompt('Value', content);
|
28
|
28
|
if (content!==null) {
|
29
|
|
- $.ajax({url:url+'/'+id, type: 'PUT', data: {content:content}, success:self.update});
|
|
29
|
+ $.ajax({url: url + '/' + id, type: 'PUT', data: {content: content}, success: self.update});
|
30
|
30
|
}
|
31
|
31
|
};
|
32
|
32
|
self.delete = function() {
|
33
|
33
|
var li = $(this).parent('li');
|
34
|
34
|
var id = li.find('span.id').text();
|
35
|
|
- if (confirm("Deleting #"+id+". Continue?")) {
|
36
|
|
- $.ajax({url:url+'/'+id, type: 'DELETE', success:self.update});
|
|
35
|
+ if (confirm("Deleting #" + id + ". Continue?")) {
|
|
36
|
+ $.ajax({url: url + '/' + id, type: 'DELETE', success: self.update});
|
37
|
37
|
}
|
38
|
38
|
};
|
39
|
39
|
self.submit = function(e) {
|
40
|
40
|
e.preventDefault();
|
41
|
41
|
var content = $(this).find('input[name="content"]').val();
|
42
|
|
- $.post(url, {user_id:1,category_id:1,content:content}, self.update);
|
|
42
|
+ $.post(url, {user_id: 1, category_id: 1, content: content}, self.update);
|
43
|
43
|
};
|
44
|
44
|
self.render = function(data) {
|
45
|
45
|
data = php_crud_api_transform(data);
|
|
@@ -58,17 +58,20 @@ function PostList(element,template) {
|
58
|
58
|
$.get(url, self.render);
|
59
|
59
|
};
|
60
|
60
|
self.post = function() {
|
61
|
|
- $.post(url, {user_id:1,category_id:1,content:"from zepto"}, self.update);
|
|
61
|
+ $.post(url, {user_id: 1, category_id: 1, content: "from zepto"}, self.update);
|
62
|
62
|
};
|
63
|
|
- element.on('submit','form',self.submit);
|
64
|
|
- element.on('click','a.edit',self.edit)
|
65
|
|
- element.on('click','a.delete',self.delete)
|
|
63
|
+ element.on('submit', 'form', self.submit);
|
|
64
|
+ element.on('click', 'a.edit', self.edit);
|
|
65
|
+ element.on('click', 'a.delete', self.delete);
|
66
|
66
|
self.post();
|
67
|
67
|
};
|
68
|
|
-$(function(){ new PostList($('#PostListDiv'),$('#PostListTemplate')); });
|
|
68
|
+$(function(){
|
|
69
|
+ new PostList($('#PostListDiv'), $('#PostListTemplate'));
|
|
70
|
+});
|
69
|
71
|
</script>
|
70
|
72
|
</head>
|
71
|
73
|
<body>
|
72
|
74
|
<div id="PostListDiv">Loading...</div>
|
73
|
75
|
</body>
|
74
|
76
|
</html>
|
|
77
|
+
|