Skip to content

Commit

Permalink
Adding counter functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamarora committed Sep 6, 2016
1 parent d583c4f commit c3e588d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions client/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ var TodoApp = React.createClass({
var _data = this.state.data;
_data.push({_id: todo._id, text: todo.text, done: todo.done});
this.setState({data: _data});
cb();
if(typeof cb === "function") {
cb();
}
}.bind(this)
});
},
Expand All @@ -53,7 +55,9 @@ var TodoApp = React.createClass({
}
});
this.setState({data: _data});
cb();
if(typeof cb === "function") {
cb();
}
}.bind(this)
});
},
Expand All @@ -66,7 +70,9 @@ var TodoApp = React.createClass({
return d._id !== id;
})
this.setState({data: _data});
cb();
if(typeof cb === "function") {
cb();
}
}.bind(this)
})
},
Expand All @@ -76,7 +82,7 @@ var TodoApp = React.createClass({
<TodoAdd addTodo={this.addTodo} />
<TodoList updateTodo={this.updateTodo} deleteTodo={this.deleteTodo} data={this.state.data} />
<div className="row">
<TodoCounter />
<TodoCounter data={this.state.data} />
<TodoFilter />
<TodoClear />
</div>
Expand Down Expand Up @@ -176,7 +182,7 @@ var TodoCounter = React.createClass({
render: function() {
return(
<div className="col-xs-12 col-sm-4 text-center">
<span className="count">3</span> todos
<span className="count">{this.props.data.length}</span> todos
</div>
);
}
Expand Down

0 comments on commit c3e588d

Please sign in to comment.