Skip to content

Instantly share code, notes, and snippets.

@codemwnci
Created August 25, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemwnci/bc87ef8ce8cf8741cedd7a7b48867ca5 to your computer and use it in GitHub Desktop.
Save codemwnci/bc87ef8ce8cf8741cedd7a7b48867ca5 to your computer and use it in GitHub Desktop.
update todo vuejs / toggleCheck method
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