var Table = React.createClass({ // TODO: Declare all propTypes propTypes: { title: React.PropTypes.string, id: React.PropTypes.number, url: React.PropTypes.string }, getInitialState: function() { return { data: null, id: "", title: "" }; }, loadTableFromServer: function() { $.getJSON(this.props.url, function(result) { if (this.isMounted()) { this.setState({ data: result }); } }.bind(this)); }, componentDidMount: function() { this.loadTableFromServer(); }, handleSeatSubmit: function(seat_id, action) { console.log("handleSeatSubmit"); $.ajax({ url: window.location.pathname + '/seats/' + seat_id + '/' + action, type: 'PATCH', dataType: 'json', success: function (data, textStatus, jqXHR) { // success callback console.log(data.message); this.loadTableFromServer(); }.bind(this), error: function (jqXHR, textStatus, errorThrown) { // error callback console.log(data.message); } }); }, render: function() { if (!this.state.data) { return
Loading...
; } return (

{this.state.data.title}

{/* TODO: DEPRECATED seats are now rendered within games */}
); } });