Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

how to manage onsubmit event of a form #76

Closed
binaryhq opened this issue Apr 27, 2016 · 2 comments
Closed

how to manage onsubmit event of a form #76

binaryhq opened this issue Apr 27, 2016 · 2 comments

Comments

@binaryhq
Copy link

binaryhq commented Apr 27, 2016

Hi I'm a beginner to react. I understand that express-react-views can handle the server side rendering of view. In that i don't need to write javascript externally. correct me if i'm wrong,

Now I was going through the react tutorial https://facebook.github.io/react/docs/tutorial.html.
I want to handle the onsumit event of a form,

var AuthForm = React.createClass({
    handleSubmit: function (e) {
        e.preventDefault();
        console.log("submit event fired!!")
       // do something
    },
    render: function () {
        return (
                    <form className="AuthForm"  onSubmit={this.handleSubmit}>
                                <input type="text" placeholder="Username" />
                                <input type="text" placeholder="code" />
                                <input type="submit" value="Login" className="button" />
                    </form>
               );
    }
})
@binaryhq binaryhq changed the title how to manage onsubmit event of a forrm how to manage onsubmit event of a form Apr 27, 2016
@toberoo
Copy link

toberoo commented Apr 27, 2016

So this library is intended to replace html/jade/mustache templates. It is a way to use react to deliver static information. Rendering dynamic components require some workarounds, check out : https://github.com/reactjs/express-react-views/blob/master/examples/dynamic/views/Html.js and the dynamic example in general. Saying that, I feel like the form submit shouldn't require that.

@zpao
Copy link
Member

zpao commented Apr 28, 2016

This project doesn't do anything client-side at the moment. If you would like to run React code on the client you'll have to manage that yourself (there's 1 example in the repo and a couple PRs with attempts to integrate better).

@zpao zpao closed this as completed Apr 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants