Commit 4cab0659 authored by addyosmani's avatar addyosmani

Completing routing changes.

parent 9fd0c4f7
// Load the application once the DOM is ready, using `jQuery.ready`: // Load the application once the DOM is ready, using `jQuery.ready`:
$(function(){ $(function(){
var currentFilter = "";
// Todo Model // Todo Model
// ---------- // ----------
...@@ -73,6 +71,10 @@ $(function(){ ...@@ -73,6 +71,10 @@ $(function(){
// Create our global collection of **Todos**. // Create our global collection of **Todos**.
var Todos = new TodoList; var Todos = new TodoList;
// Todo Filter (active || completed || "")
var TodoFilter = "";
// Todo Item View // Todo Item View
// -------------- // --------------
...@@ -198,6 +200,13 @@ $(function(){ ...@@ -198,6 +200,13 @@ $(function(){
completed: completed, completed: completed,
remaining: remaining remaining: remaining
})); }));
this.$('#filters li a')
.removeClass('selected')
.filter("[href='#/" + TodoFilter + "']")
.addClass('selected');
} else { } else {
this.$main.hide(); this.$main.hide();
...@@ -219,7 +228,7 @@ $(function(){ ...@@ -219,7 +228,7 @@ $(function(){
this.$("#todo-list").html(''); this.$("#todo-list").html('');
switch(currentFilter){ switch(TodoFilter){
case "active": case "active":
_.each(Todos.remaining(), this.addOne); _.each(Todos.remaining(), this.addOne);
break; break;
...@@ -275,15 +284,11 @@ $(function(){ ...@@ -275,15 +284,11 @@ $(function(){
setFilter: function(param){ setFilter: function(param){
currentFilter = param; // Set the current filter to be used
Todos.trigger('reset'); TodoFilter = param || "";
// Currently not working on navigation.
$('#filters li a')
.removeClass('selected')
.filter("[href='#/" + param + "']")
.addClass('selected');
// Trigger a collection reset/addAll
Todos.trigger('reset');
} }
......
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