Created
August 25, 2017 22:06
-
-
Save codemwnci/bc87ef8ce8cf8741cedd7a7b48867ca5 to your computer and use it in GitHub Desktop.
update todo vuejs / toggleCheck method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toggleCheck: function(todo) { | |
todo.done = !todo.done; | |
this.update(todo); | |
}, | |
update: function(todo) { | |
axios.put("http://localhost:9000/todo/"+todo.id, {"text": todo.text, "done": todo.done}).then(response => { | |
for(var i = this.todos.length; i--;){ | |
if (this.todos[i].id === todo.id) { | |
this.todos[i].done = response.data.done; | |
this.todos[i].text = response.data.text; | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment