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 1
1
var React = require ( 'react' ) ;
2
+ var Firebase = require ( 'firebase' ) ;
3
+ var rootUrl = 'https://blistering-torch-4253.firebaseio.com/' ;
2
4
3
5
module . exports = React . createClass ( {
4
6
getInitialState : function ( ) {
5
7
return {
6
- text : this . props . item . text
8
+ text : this . props . item . text ,
9
+ done : this . props . item . done
7
10
}
8
11
} ,
12
+ componentWillMount : function ( ) {
13
+ this . fb = new Firebase ( rootUrl + 'items/' + this . props . item . id ) ;
14
+ } ,
9
15
render : function ( ) {
10
16
return < div className = "input-group" >
11
17
< span className = "input-group-addon" >
12
- < input type = "checkbox" />
18
+ < input
19
+ type = "checkbox"
20
+ checked = { this . state . done }
21
+ onChange = { this . handleDoneChange }
22
+ />
13
23
</ span >
14
24
< input type = "text"
15
25
className = "form-control"
@@ -21,5 +31,10 @@ module.exports = React.createClass({
21
31
</ button >
22
32
</ span >
23
33
</ div >
34
+ } ,
35
+ handleDoneChange : function ( event ) {
36
+ var update = { done : event . target . checked }
37
+ this . setState ( update ) ;
38
+ this . fb . update ( update ) ;
24
39
}
25
40
} ) ;
You can’t perform that action at this time.
0 commit comments