Skip to content

Commit

Permalink
Firebase - Section 11
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jun 6, 2015
1 parent 323226d commit a466ecb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions todos/src/list-item.jsx
@@ -1,15 +1,25 @@
var React = require('react');
var Firebase = require('firebase');
var rootUrl = 'https://blistering-torch-4253.firebaseio.com/';

module.exports = React.createClass({
getInitialState: function() {
return {
text: this.props.item.text
text: this.props.item.text,
done: this.props.item.done
}
},
componentWillMount: function() {
this.fb = new Firebase(rootUrl + 'items/' + this.props.item.id);
},
render: function() {
return <div className="input-group">
<span className="input-group-addon">
<input type="checkbox" />
<input
type="checkbox"
checked={this.state.done}
onChange={this.handleDoneChange}
/>
</span>
<input type="text"
className="form-control"
Expand All @@ -21,5 +31,10 @@ module.exports = React.createClass({
</button>
</span>
</div>
},
handleDoneChange: function(event) {
var update = {done: event.target.checked}
this.setState(update);
this.fb.update(update);
}
});

0 comments on commit a466ecb

Please sign in to comment.