Cs fixes
This commit is contained in:
parent
bd2dcdf87e
commit
ec6fa53be4
1 changed files with 13 additions and 10 deletions
|
|
@ -24,22 +24,22 @@ function PostList(element,template) {
|
|||
var li = $(this).parent('li');
|
||||
var id = li.find('span.id').text();
|
||||
var content = li.find('span.content').text();
|
||||
content = prompt('Value',content);
|
||||
content = prompt('Value', content);
|
||||
if (content!==null) {
|
||||
$.ajax({url:url+'/'+id, type: 'PUT', data: {content:content}, success:self.update});
|
||||
$.ajax({url: url + '/' + id, type: 'PUT', data: {content: content}, success: self.update});
|
||||
}
|
||||
};
|
||||
self.delete = function() {
|
||||
var li = $(this).parent('li');
|
||||
var id = li.find('span.id').text();
|
||||
if (confirm("Deleting #"+id+". Continue?")) {
|
||||
$.ajax({url:url+'/'+id, type: 'DELETE', success:self.update});
|
||||
if (confirm("Deleting #" + id + ". Continue?")) {
|
||||
$.ajax({url: url + '/' + id, type: 'DELETE', success: self.update});
|
||||
}
|
||||
};
|
||||
self.submit = function(e) {
|
||||
e.preventDefault();
|
||||
var content = $(this).find('input[name="content"]').val();
|
||||
$.post(url, {user_id:1,category_id:1,content:content}, self.update);
|
||||
$.post(url, {user_id: 1, category_id: 1, content: content}, self.update);
|
||||
};
|
||||
self.render = function(data) {
|
||||
data = php_crud_api_transform(data);
|
||||
|
|
@ -58,17 +58,20 @@ function PostList(element,template) {
|
|||
$.get(url, self.render);
|
||||
};
|
||||
self.post = function() {
|
||||
$.post(url, {user_id:1,category_id:1,content:"from zepto"}, self.update);
|
||||
$.post(url, {user_id: 1, category_id: 1, content: "from zepto"}, self.update);
|
||||
};
|
||||
element.on('submit','form',self.submit);
|
||||
element.on('click','a.edit',self.edit)
|
||||
element.on('click','a.delete',self.delete)
|
||||
element.on('submit', 'form', self.submit);
|
||||
element.on('click', 'a.edit', self.edit);
|
||||
element.on('click', 'a.delete', self.delete);
|
||||
self.post();
|
||||
};
|
||||
$(function(){ new PostList($('#PostListDiv'),$('#PostListTemplate')); });
|
||||
$(function(){
|
||||
new PostList($('#PostListDiv'), $('#PostListTemplate'));
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="PostListDiv">Loading...</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue