Browse Source

add loader to delete, simplify loading state

pull/1/head
wes 8 years ago
parent
commit
5bd3c00c58
  1. 5
      src/scripts/editor.tag

5
src/scripts/editor.tag

@ -213,12 +213,11 @@ submit() {
loadPost(_id) { loadPost(_id) {
return function() { return function() {
console.log("started loading"); console.log("started loading");
self.update({"loading" : true});
if (!_id) { if (!_id) {
console.log("couldn't load the post"); console.log("couldn't load the post");
self.update({"loading" : false});
return false; return false;
} }
self.update({"loading" : true});
axios.get(`/blog/getpost/${_id}`) axios.get(`/blog/getpost/${_id}`)
.then(function(resp) { .then(function(resp) {
self.update({"loading" : false}); self.update({"loading" : false});
@ -244,10 +243,12 @@ deletePost(_id) {
if (!_id) { if (!_id) {
return false; return false;
} }
self.update({"loading" : true});
axios.get(`/blog/deletepost/${self._id}`) axios.get(`/blog/deletepost/${self._id}`)
.then(function(resp) { .then(function(resp) {
console.log(resp); console.log(resp);
self.listPosts(); self.listPosts();
self.update({"loading" : false});
}) })
.catch(function(err) { .catch(function(err) {
console.log(err); console.log(err);

Loading…
Cancel
Save