Skip to content

Commit

Permalink
Firebase - Section 14
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jun 7, 2015
1 parent f3d0640 commit 4650605
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions todos/src/list-item.jsx
Expand Up @@ -23,6 +23,7 @@ module.exports = React.createClass({
/>
</span>
<input type="text"
disabled={this.state.done}
className="form-control"
value={this.state.text}
onChange={this.handleTextChange}
Expand All @@ -42,12 +43,32 @@ module.exports = React.createClass({
if(!this.state.textChanged) {
return null
} else {
return <span>
<button className="btn btn-default">Save</button>
<button className="btn btn-default">Undo</button>
</span>
return [
<button
className="btn btn-default"
onClick={this.handleSaveClick}
>
Save
</button>,
<button
onClick={this.handleUndoClick}
className="btn btn-default"
>
Undo
</button>
]
}
},
handleSaveClick: function() {
this.fb.update({text: this.state.text});
this.setState({textChanged: false});
},
handleUndoClick: function() {
this.setState({
text: this.props.item.text,
textChanged: false
});
},
handleTextChange: function(event) {
this.setState({
text: event.target.value,
Expand Down

0 comments on commit 4650605

Please sign in to comment.