Created
March 6, 2015 00:55
-
-
Save akatreyt/17eb5f1ed1d21093411b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
var React = require('react'); | |
var BuildingAppStore = require('./building-store.js'); | |
var Buildingview = require('./building-buildingDetail.js'); | |
var EditBuilding = require('./building-editBuilding.js'); | |
function getBuildings(){ | |
return {items: BuildingAppStore.getBuildings()}; | |
} | |
var Buildings = React.createClass({ | |
getInitialState:function(){ | |
return getBuildings(); | |
}, | |
componentWillMount:function(){ | |
BuildingAppStore.addChangeListener(this._onChange); | |
}, | |
componentWillUnmount:function(){ | |
BuildingAppStore.removeChangeListener(this._onChange); | |
}, | |
_onChange:function(){ | |
this.setState(getBuildings()); | |
}, | |
handleEditBuilding:function(item){ | |
console.log(item); | |
}, | |
render: function() { | |
var buildings = this.state.items.map(function(item){ | |
return <Buildingview key={item.id} item={item} onEditBuilding={this.handleEditBuilding} /> | |
}) | |
return ( | |
<div> | |
<div className="col-md-6"> | |
{buildings} | |
</div> | |
<div className="col-md-6"> | |
<EditBuilding /> | |
</div> | |
</div> | |
) | |
} | |
}); | |
module.exports = Buildings; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment