React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-0.14.0.js"></script>
<script src="https://fb.me/react-dom-0.14.0.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="example">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var DeliveryOptionsTHeadTh = React.createClass({
render: function() {
return (
<th>{this.props.label}</th>
);
}
});
var DeliveryOptionsTHead = React.createClass({
getInitialState : function(){
return {
data: {
days: []
}
}
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
console.log(result);
this.setState({data: result});
}.bind(this));
},
render: function() {
var days = this.state.data.days.map(function (day) {
return <DeliveryOptionsTHeadTh label={day.label} key={ day.date } />;
});
return (
<thead>
<tr>{ days }</tr>
</thead>
);
}
});
var DeliveryOptionsTable = React.createClass({
render: function() {
return (
<table className='pure-table pure-table-horizontal'>
<DeliveryOptionsTHead source="http://delivery.ubermartapps.nl/options/plus_496" />
<tbody>
</tbody>
</table>
);
}
});
ReactDOM.render(
<DeliveryOptionsTable />,
document.getElementById('example')
)