Skip to content

Commit

Permalink
handle empty edit
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 1, 2015
1 parent 437c43b commit 3ffbeee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions example/src/components/todo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export default {
},
methods: {
doneEdit (e) {
if (this.editing) {
flux.dispatch('EDIT_TODO', this.todo, e.target.value)
var value = e.target.value.trim()
if (!value) {
flux.dispatch('DELETE_TODO', this.todo)
} else if (this.editing) {
flux.dispatch('EDIT_TODO', this.todo, value)
this.editing = false
}
},
Expand Down

0 comments on commit 3ffbeee

Please sign in to comment.