The library for web and native user interfaces.
sync more with backbone
petehunt committed
May 30, 2013 at 04:18 UTC
875782cc0a662ccbee485ba08df3fb8c0ace8592
1 file changed
+5
-1
examples/todomvc-backbone/js/app.js
+5
-1
@@ -46,6 +46,10 @@ var TodoList = Backbone.Collection.extend({
46
});
47
},
48
49
+ remaining: function() {
50
+ return this.without.apply(this, this.completed());
51
+ },
52
+
53
// We keep the Todos in sequential order, despite being saved by unordered
54
// GUID in the database. This generates the next order number for new items.
55
nextOrder: function () {
@@ -184,7 +188,7 @@ var TodoApp = React.createClass({
188
return <TodoItem todo={todo} onToggle={todo.toggle.bind(todo)} onDestroy={this.destroy.bind(this, todo)} onEdit={this.edit.bind(this, todo)} editing={this.state.editing === todo.get('id')} onSave={this.save.bind(this, todo)} />;
189
}.bind(this));
190
187
- var activeTodoCount = this.props.todos.filter(function(todo) { return !todo.get('completed') }).length;
191
+ var activeTodoCount = this.props.todos.remaining().length;
192
var completedCount = todoItems.length - activeTodoCount;
193
if (activeTodoCount || completedCount) {
194
footer = <TodoFooter count={activeTodoCount} completedCount={completedCount} onClearCompleted={this.clearCompleted.bind(this)} />;