Last active
December 17, 2015 21:28
-
-
Save arbales/5674453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="commentForm" onSubmit={this.handleSubmit}> | |
<input type="text" placeholder="Your name" ref="author" /> | |
<input | |
type="text" | |
placeholder="Say something..." | |
ref="text" | |
/> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tutorial16.js | |
var CommentForm = React.createClass({ | |
templateName: 'comment_form', | |
handleSubmit: React.autoBind(function() { | |
var author = this.refs.author.getDOMNode().value.trim(); | |
var text = this.refs.text.getDOMNode().value.trim(); | |
if (!text || !author) { | |
return; | |
} | |
// TODO: send request to the server | |
this.refs.author.getDOMNode().value = ''; | |
this.refs.text.getDOMNode().value = ''; | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment