Permalink
Browse files

fixed filtering

  • Loading branch information...
1 parent 2ef2482 commit 9feda9c7b62ed4c8a735206e2dfcbb0868817eab @derickbailey committed Sep 7, 2012
View
6 labs/architecture-examples/backbone_marionette_modules/index.html
@@ -15,13 +15,13 @@
<span id="todo-count"><strong></strong> items left</span>
<ul id="filters">
<li>
- <a href="#/">All</a>
+ <a href="#">All</a>
</li>
<li>
- <a href="#/active">Active</a>
+ <a href="#active">Active</a>
</li>
<li>
- <a href="#/completed">Completed</a>
+ <a href="#completed">Completed</a>
</li>
</ul>
<button id="clear-completed">Clear completed</button>
View
2 labs/architecture-examples/backbone_marionette_modules/js/TodoMVC.Layout.js
@@ -69,7 +69,7 @@ TodoMVC.module("Layout", function(Layout, App, Backbone, Marionette, $, _){
updateFilterSelection : function(filter) {
this.ui.filters
.removeClass('selected')
- .filter('[href="#/' + filter + '"]')
+ .filter('[href="#' + filter + '"]')
.addClass('selected');
},
View
11 labs/architecture-examples/backbone_marionette_modules/js/TodoMVC.TodoList.Views.js
@@ -102,4 +102,15 @@ TodoMVC.module("TodoList.Views", function(Views, App, Backbone, Marionette, $, _
}
});
+ // Application Event Handlers
+ // --------------------------
+ //
+ // Handler for filtering the list of items by showing and
+ // hiding through the use of various CSS classes
+
+ App.vent.on('todoList:filter',function(filter) {
+ filter = filter || 'all';
+ $('#todoapp').attr('class', 'filter-' + filter);
+ });
+
});
View
23 labs/architecture-examples/backbone_marionette_modules/js/TodoMVC.TodoList.js
@@ -7,8 +7,7 @@ TodoMVC.module("TodoList", function(TodoList, App, Backbone, Marionette, $, _){
TodoList.Router = Marionette.AppRouter.extend({
appRoutes : {
- "": "showActiveItems",
- "*filter": "showFilteredItems"
+ "*filter": "filterItems"
}
});
@@ -54,14 +53,9 @@ TodoMVC.module("TodoList", function(TodoList, App, Backbone, Marionette, $, _){
}));
},
- // Set the filter to show active items only
- showActiveItems: function(){
- App.vent.trigger("todoList:filter", "");
- },
-
// Set the filter to show complete or all items
- showFilteredItems: function(filter){
- App.vent.trigger("todoList:filter", filter.trim());
+ filterItems: function(filter){
+ App.vent.trigger("todoList:filter", filter.trim() || "");
}
});
@@ -83,15 +77,4 @@ TodoMVC.module("TodoList", function(TodoList, App, Backbone, Marionette, $, _){
});
- // Application Event Handlers
- // --------------------------
- //
- // Handler for filtering the list of items by showing and
- // hiding through the use of various CSS classes
-
- TodoMVC.vent.on('todoList:filter',function(filter) {
- filter = filter || 'all';
- $('#todoTodoMVC').attr('class', 'filter-' + filter);
- });
-
});

0 comments on commit 9feda9c

Please sign in to comment.