refactoring working, will need to reorganize stuff a little bit

This commit is contained in:
Edin Dazdarevic
2015-01-25 12:52:31 +01:00
parent 2ad4e4a766
commit 769230eda1
12 changed files with 83 additions and 142 deletions

View File

@@ -3,30 +3,57 @@ var React = require('react'),
ItemActions = require('../actions/itemActions'),
ItemStore = require('../stores/itemStore');
var Item = require('../models/item');
var Router = require('react-router');
var Navigation = Router.Navigation;
var ItemWithDetailsPage = React.createClass({
mixins : [Router.State],
render: function() {
return (
<div className="item-with-details row-fluid center">
<div className="item-with-details row-fluid center">
<div className="span3">
<ItemMultiMediaDescriptions descriptions={this.state.item.get('multi_media_descriptions')} />
</div>
<h3> {this.state.item.get('name')} </h3>
<div>
<div className='h4'> {this.state.item.get('list_price')} KM</div>
<div> {this.state.item.get('description')}</div>
</div>
<ItemMultiMediaDescriptions descriptions={this.state.item.get('multi_media_descriptions')} />
</div>
<div className="span4">
quantitative descriptions
</div>
</div>
) ;
},
// Add change listeners to stores
componentDidMount: function() {
ItemStore.addChangeListener(this._onChange);
ItemActions.loadFrontPageItems();
//ItemStore.addChangeListener(this._onChange);
//ItemActions.loadFrontPageItems();
var self = this;
var item = new Item({ id: self.getParams().id });
item.fetch({success: function() {
if (self.isMounted()) {
console.log('article loaded', item);
self.setState({
item : item
});
}
}});
},
_onChange: function () {
@@ -36,7 +63,10 @@ var ItemWithDetailsPage = React.createClass({
},
getInitialState: function () {
return { item: ItemStore.getSelectedItem() };
return {
//item: ItemStore.getSelectedItem()
item : (new Item())
};
}
});