Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SelectElement extends React.PureComponent {
- constructor(props) {
- super(props);
- this.state = {
- optionList: []
- };
- }
- finalize() {
- // this means "window" in this case... so all the code below barfs:
- let key = this.props.inputName;
- let val = this.state.text;
- let postObj = {};
- postObj[key] = val;
- console.dir(postObj);
- $.post($.endPoints.saveCallField, postObj).done(function (response) {
- console.dir(response);
- });
- }
- render() {
- this.props.options.forEach(option =>
- this.state.optionList.push(<OptionElement value={option} text={option }/>)
- );
- return (
- <React.Fragment>
- <select className="form-control callField" name={this.props.inputName}
- onChange={this.finalize}>
- {this.state.optionList}
- </select>
- </React.Fragment>
- );
- }
- }
Add Comment
Please, Sign In to add comment