File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 11var React = require ( 'react' ) ;
2+ var Firebase = require ( 'firebase' ) ;
3+ var rootUrl = 'https://blistering-torch-4253.firebaseio.com/' ;
24
35module . exports = React . createClass ( {
46 getInitialState : function ( ) {
57 return {
6- text : this . props . item . text
8+ text : this . props . item . text ,
9+ done : this . props . item . done
710 }
811 } ,
12+ componentWillMount : function ( ) {
13+ this . fb = new Firebase ( rootUrl + 'items/' + this . props . item . id ) ;
14+ } ,
915 render : function ( ) {
1016 return < div className = "input-group" >
1117 < span className = "input-group-addon" >
12- < input type = "checkbox" />
18+ < input
19+ type = "checkbox"
20+ checked = { this . state . done }
21+ onChange = { this . handleDoneChange }
22+ />
1323 </ span >
1424 < input type = "text"
1525 className = "form-control"
@@ -21,5 +31,10 @@ module.exports = React.createClass({
2131 </ button >
2232 </ span >
2333 </ div >
34+ } ,
35+ handleDoneChange : function ( event ) {
36+ var update = { done : event . target . checked }
37+ this . setState ( update ) ;
38+ this . fb . update ( update ) ;
2439 }
2540} ) ;
You can’t perform that action at this time.
0 commit comments