File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments