summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-07-17 15:03:59 -0600
committermo khan <mo@mokhan.ca>2013-07-17 15:03:59 -0600
commit0c8521a715de976fe253e6ae59f6ed5ae41a2664 (patch)
tree987078e2b9fc9ad8b0703809e52b0d3add6ed7b1
parent71f64b55eefa356ae21437e7163e76204957fca2 (diff)
add route to completed todos
-rw-r--r--index.html2
-rw-r--r--js/router.js12
2 files changed, 13 insertions, 1 deletions
diff --git a/index.html b/index.html
index e64bcfa..709e36b 100644
--- a/index.html
+++ b/index.html
@@ -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 });
+ }
+});