Skip to content

Commit 4650605

Browse files
committed
Firebase - Section 14
1 parent f3d0640 commit 4650605

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

todos/src/list-item.jsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = React.createClass({
2323
/>
2424
</span>
2525
<input type="text"
26+
disabled={this.state.done}
2627
className="form-control"
2728
value={this.state.text}
2829
onChange={this.handleTextChange}
@@ -42,12 +43,32 @@ module.exports = React.createClass({
4243
if(!this.state.textChanged) {
4344
return null
4445
} else {
45-
return <span>
46-
<button className="btn btn-default">Save</button>
47-
<button className="btn btn-default">Undo</button>
48-
</span>
46+
return [
47+
<button
48+
className="btn btn-default"
49+
onClick={this.handleSaveClick}
50+
>
51+
Save
52+
</button>,
53+
<button
54+
onClick={this.handleUndoClick}
55+
className="btn btn-default"
56+
>
57+
Undo
58+
</button>
59+
]
4960
}
5061
},
62+
handleSaveClick: function() {
63+
this.fb.update({text: this.state.text});
64+
this.setState({textChanged: false});
65+
},
66+
handleUndoClick: function() {
67+
this.setState({
68+
text: this.props.item.text,
69+
textChanged: false
70+
});
71+
},
5172
handleTextChange: function(event) {
5273
this.setState({
5374
text: event.target.value,

0 commit comments

Comments
 (0)