var React = require('react'), Router = require('react-router'), Category = require('../../models/category'), Section = require('../../models/section'), ItemCollection = require('../../models/itemCollection'), ItemActions = require('../../actions/itemActions.js'), CategoryActions = require('../../actions/categoryActions.js'), CategoryStore = require('../../stores/categoryStore'), ItemStore = require('../../stores/itemStore'), NavigationStore = require('../../stores/navigationStore'), ItemList = require('../items/itemList'), NavigationActions = require('../../actions/navigationActions'); var ByCategory = React.createClass({ mixins: [Router.State], getInitialState: function() { var category = new Category(); var items = new ItemCollection(); return { category: category, items: items }; }, onFCClick: function(fc, fcv) { var q = {}; q[fc.field_name] = fcv.filter_value; // TODO: fix this, clean this up var section = new Section(this.state.category.get('section')); var category = this.state.category; NavigationActions.goToCategory(category, section, q) }, render: function() { var self = this; return (
{this.state.category.get('name')}
Podkategorije
{this.state.category.get('filter_criterias').map(function(fc) { return (
{fc.title}
) })}

Browse products by category : {this.state.category.get('name')}

Number of items in this category: {this.state.items.length}
need to filter brand: {this.getQuery().brand}
); }, componentWillReceiveProps: function() { var categoryId = this.getParams().id; ItemActions.loadByCategory(categoryId); CategoryActions.loadCategoryDetails(categoryId); }, componentDidMount: function() { var categoryId = this.getParams().id; ItemActions.loadByCategory(categoryId); CategoryActions.loadCategoryDetails(categoryId); ItemStore.addChangeListener(this._onChange); CategoryStore.addChangeListener(this._onChange); }, componentWillUnmount: function() { ItemStore.removeChangeListener(this._onChange); CategoryStore.removeChangeListener(this._onChange); }, _onChange: function() { if(this.isMounted()) { this.setState({ items: ItemStore.getItemsForCategory(), category: CategoryStore.getCategoryDetails() }); } } }); module.exports = ByCategory;