Commit 68f57e14 authored by Christoph Burgdorf's avatar Christoph Burgdorf

trim todos and remove them after editing if its an empty string

parent d4079224
...@@ -6,7 +6,7 @@ App.Controllers.TodoController = function () { ...@@ -6,7 +6,7 @@ App.Controllers.TodoController = function () {
self.newTodo = ""; self.newTodo = "";
self.addTodo = function() { self.addTodo = function() {
if (self.newTodo.length === 0) return; if (self.newTodo.trim().length === 0) return;
self.todos.push({ self.todos.push({
content: self.newTodo, content: self.newTodo,
...@@ -25,7 +25,12 @@ App.Controllers.TodoController = function () { ...@@ -25,7 +25,12 @@ App.Controllers.TodoController = function () {
}; };
self.finishEditing = function(todo) { self.finishEditing = function(todo) {
if (todo.content.trim().length === 0){
self.removeTodo(todo);
}
else{
todo.editing = false; todo.editing = false;
}
}; };
self.removeTodo = function(todo) { self.removeTodo = function(todo) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment