i_trope i_trope - 19 days ago 6
React JSX Question

React - on form submit get POST params

I am using React, and would like to retrieve POST params from a form (see below):

<form ref='form' className="form">
<input type="text" className="signup-input" />
<input type="text" className="signup-input" />
<button className="btn btn-primary" onClick={this._onSubmitClick}>Submit</button>
</form>


In the
_onSubmitClick
callback, I would like to achieve the same results as calling
$(".form").serialize()
but without using JQuery.

Joe Joe
Answer
var elements = this.refs.form.getDOMNode().elements;

gives you an object containing each of the input nodes, which you could then iterate through.