Hey guys,
I’m working on my first meteor project, and ran into some problems…
When submitting the form, the onSubmit function is not running. Any idea why?
This is my code:
GameForm = React.createClass({
handleSubmit(event) {
event.preventDefault();
var author = this.refs.author.value.trim();
var text = this.refs.text.value.trim();
if (!text || !author) {
return;
}
console.log("test");
console.log(author);
// TODO: send request to the server
this.refs.author.value = '';
this.refs.text.value = '';
return;
},
/*componentDidMount: function() {
$('.commentForm').on('submit', this.handleSubmit);
},*/
render() {
return (
<div id="main">
<div className="form-wrapper">
<div className="single-page-form-container">
<div className="container-title" onClick={this.displayLog}>Create Betakey</div>
<div className="container-content">
<form className="commentForm" onSubmit={this.handleSubmit} >
<input type="text" placeholder="Your name" ref="author" />
<input type="text" placeholder="Say something..." ref="text" />
<input type="submit" />
</form>
</div>
</div>
</div>
</div>
);
}
});