Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. var ClientForm = React.createClass({
  2.  
  3. getInitialState: function() {
  4. return ({
  5. editing: _getEditing()
  6. });
  7. },
  8.  
  9. handleSubmit: function() {
  10. ClientActions.create('bob','eat_out');
  11. return false;
  12. },
  13.  
  14. componentDidMount: function() {
  15. ClientStore.addChangeListener(this._onChange);
  16. },
  17.  
  18. componentWillUnmount: function() {
  19. ClientStore.removeChangeListener(this._onChange);
  20. },
  21.  
  22. render: function() {
  23. // TODO: add parsely data attributes to form and inputs
  24. var name = (this.state.editing == null) ? '' : this.state.editing.name;
  25. var client_type = (this.state.editing == null) ? '' : this.state.editing.client_type;
  26.  
  27. console.log(name);
  28. return (
  29. <form role="form" onSubmit={this.handleSubmit}>
  30. <div className="form-group">
  31. <label>Name</label>
  32. <input type="text" className="form-control" defaultValue={name}/>
  33. </div>
  34. <div className="form-group">
  35. <label>Client Type</label>
  36. <select name="client_type" className="form-control" defaultValue={client_type}>
  37. <option>Choose one</option>
  38. <option value="cook">Cook</option>
  39. <option value="eat_out">Eat Out</option>
  40. </select>
  41. </div>
  42. <button type="submit" className="btn btn-default">Submit</button>
  43. </form>
  44. );
  45. },
  46.  
  47. _onChange: function() {
  48. this.setState({
  49. editing: _getEditing()
  50. });
  51. }
  52.  
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement