Commit 7d56ad3f authored by Fred Wu's avatar Fred Wu

Clear the input text field after adding a new entry

parent d95b22b7
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
TaskApp.prototype.elements = { TaskApp.prototype.elements = {
'.items': 'tasks', '.items': 'tasks',
'.countVal': 'counter', '.countVal': 'counter',
'a.clear': 'clearCompleted' 'a.clear': 'clearCompleted',
'form#new-task input[name=name]': 'newTaskName'
}; };
TaskApp.prototype.events = { TaskApp.prototype.events = {
...@@ -31,7 +32,8 @@ ...@@ -31,7 +32,8 @@
TaskApp.prototype["new"] = function(e) { TaskApp.prototype["new"] = function(e) {
e.preventDefault(); e.preventDefault();
return Task.fromForm('form#new-task').save(); Task.fromForm('form#new-task').save();
return this.newTaskName.val('');
}; };
TaskApp.prototype.renderNew = function(task) { TaskApp.prototype.renderNew = function(task) {
......
...@@ -3,6 +3,7 @@ class TaskApp extends Spine.Controller ...@@ -3,6 +3,7 @@ class TaskApp extends Spine.Controller
'.items': 'tasks' '.items': 'tasks'
'.countVal': 'counter' '.countVal': 'counter'
'a.clear': 'clearCompleted' 'a.clear': 'clearCompleted'
'form#new-task input[name=name]': 'newTaskName'
events: events:
'submit form#new-task': 'new' 'submit form#new-task': 'new'
...@@ -19,6 +20,7 @@ class TaskApp extends Spine.Controller ...@@ -19,6 +20,7 @@ class TaskApp extends Spine.Controller
new: (e) -> new: (e) ->
e.preventDefault() e.preventDefault()
Task.fromForm('form#new-task').save() Task.fromForm('form#new-task').save()
@newTaskName.val('')
renderNew: (task) => renderNew: (task) =>
view = new Tasks(task: task) view = new Tasks(task: task)
......
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