I have the following response component that retrieves Ajax data on page load as follows:
var MyTable = React.createClass({ getInitialState: function() { return { rows: [ ['Something, ' '], ['Something else', ' '] ] }; }, componentDidMount: function() { var self = this; $.get('http://domain.com/api/Orders/from-date/' + fromDate + '/to-date/' + toDate, function(result) { var newState = React.addons.update(this.state, { rows: { 0: { 1: { $set: result } } } }); this.setState(newState); }.bind(this) ); }, render: function() { return ( <Table rowHeight={50} rowGetter={(rowIndex) => { return this.state.rows[rowIndex]; }} rowsCount={this.state.rows.length} onRowClick={this._onRowClick} width={1000} height={342} groupHeaderHeight={40} headerHeight={0}> <ColumnGroup label="Products" fixed={true}> <Column label="" width={col1} dataKey={0} /> <Column label="" width={700} dataKey={1} /> </ColumnGroup> </Table> ); } }); MyTable = React.createFactory(MyTable ) React.render(MyTable(), document.getElementById('my-table-container') );
My problem is that I cannot override the component when the date is changed with datepicker, so the Ajax date parameter is changing, and I need to make another request with these new values.
What I tried:
$(function(){ $("#calculate-orders").on("click",function(){ fromDate = document.getElementById("from-date").value; toDate = document.getElementById("to-date").value; React.render(MyTable(), document.getElementById('my-table-container') ); }) })
But nothing happens. How can i solve this? And this can only be done using JavaScript / jsx, without the need for a thread and, most importantly, without node.js?
Ps. I am using FixedDataTable in this example.
source share