diff options
| author | mo khan <mo@mokhan.ca> | 2013-07-17 15:03:59 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-07-17 15:03:59 -0600 |
| commit | 0c8521a715de976fe253e6ae59f6ed5ae41a2664 (patch) | |
| tree | 987078e2b9fc9ad8b0703809e52b0d3add6ed7b1 | |
| parent | 71f64b55eefa356ae21437e7163e76204957fca2 (diff) | |
add route to completed todos
| -rw-r--r-- | index.html | 2 | ||||
| -rw-r--r-- | js/router.js | 12 |
2 files changed, 13 insertions, 1 deletions
@@ -30,7 +30,7 @@ {{#linkTo 'todos.active' activeClass="selected"}}Active{{/linkTo}} </li> <li> - <a href="completed">Completed</a> + {{#linkTo 'todos.completed' activeClass="selected"}}Completed{{/linkTo}} </li> </ul> diff --git a/js/router.js b/js/router.js index 79f9ad0..a2bd7f9 100644 --- a/js/router.js +++ b/js/router.js @@ -1,6 +1,7 @@ Todos.Router.map(function(){ this.resource('todos', { path: '/' }, function() { this.route('active'); + this.route('completed'); }); }); @@ -26,3 +27,14 @@ Todos.TodosActiveRoute = Ember.Route.extend({ this.render('todos/index', { controller: controller }); } }); + +Todos.TodosCompletedRoute = Ember.Route.extend({ + model: function() { + return Todos.Todo.filter(function(todo){ + if (todo.get('isCompleted')) { return true; } + }); + }, + renderTemplate: function(controller) { + this.render('todos/index', { controller: controller }); + } +}); |
