Guest User

Untitled

a guest
Apr 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. class SelectElement extends React.PureComponent {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. optionList: []
  6. };
  7. }
  8.  
  9. finalize() {
  10. // this means "window" in this case... so all the code below barfs:
  11. let key = this.props.inputName;
  12. let val = this.state.text;
  13. let postObj = {};
  14. postObj[key] = val;
  15. console.dir(postObj);
  16. $.post($.endPoints.saveCallField, postObj).done(function (response) {
  17. console.dir(response);
  18. });
  19. }
  20.  
  21. render() {
  22. this.props.options.forEach(option =>
  23. this.state.optionList.push(<OptionElement value={option} text={option }/>)
  24. );
  25. return (
  26. <React.Fragment>
  27. <select className="form-control callField" name={this.props.inputName}
  28. onChange={this.finalize}>
  29. {this.state.optionList}
  30. </select>
  31. </React.Fragment>
  32. );
  33. }
  34. }
Add Comment
Please, Sign In to add comment