From 0032069c279f5ef851de52d0d3b72a2a79aa4ff6 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Sat, 1 Nov 2014 15:19:10 +0100 Subject: [PATCH] using location.hash to initialize tabview correctly --- public/js/components/TabView.jsx | 12 ++++++++++++ public/js/components/strategy/Strategy.jsx | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 public/js/components/strategy/Strategy.jsx diff --git a/public/js/components/TabView.jsx b/public/js/components/TabView.jsx index 687949699d..b1ad225b09 100644 --- a/public/js/components/TabView.jsx +++ b/public/js/components/TabView.jsx @@ -9,6 +9,18 @@ var TabView = React.createClass({ return {activeTab: this.props.tabPanes[0]}; }, + componentDidMount:function() { + var userHash = window.location.hash; + if(userHash) { + userHash = userHash.split("#")[1]; + this.props.tabPanes.forEach(function(pane) { + if(pane.name === userHash) { + this.setState({activeTab: pane}) + } + }.bind(this)); + } + }, + handleChangeTab: function(tabPane) { this.setState({activeTab: tabPane}); }, diff --git a/public/js/components/strategy/Strategy.jsx b/public/js/components/strategy/Strategy.jsx new file mode 100644 index 0000000000..8a0e40d92f --- /dev/null +++ b/public/js/components/strategy/Strategy.jsx @@ -0,0 +1,17 @@ +var React = require('react'); + +var StrategyList = React.createClass({ + propTypes: { + strategies: React.PropTypes.array.isRequired + }, + + render: function() { + return (
+ + {JSON.stringify(this.props.strategies)} +
+ ); + } +}); + +module.exports = StrategyList; \ No newline at end of file