Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/Tutorial: Introducing a submit button in the comment form #19

Merged
merged 1 commit into from
May 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,14 @@ var CommentForm = React.createClass({
<form class="commentForm">
<input type="text" placeholder="Your name" />
<input type="text" placeholder="Say something..." />
<input type="submit" />
</form>
);
}
});
```

Let's make the form interactive. When the user presses enter, we should clear the form, submit a request to the server, and refresh the list of comments. To start, let's listen for this event and just clear the form.
Let's make the form interactive. When the user submits the form, we should clear it, submit a request to the server, and refresh the list of comments. To start, let's listen for the form's submit event and clear it.

```javascript{3-12,15,20}
// tutorial16.js
Expand All @@ -479,6 +480,7 @@ var CommentForm = React.createClass({
placeholder="Say something..."
ref="text"
/>
<input type="submit" />
</form>
);
}
Expand Down Expand Up @@ -541,7 +543,7 @@ var CommentBox = React.createClass({
});
```

Let's call the callback from the `CommentForm` when the user presses enter:
Let's call the callback from the `CommentForm` when the user submits the form:

```javascript{6}
// tutorial18.js
Expand All @@ -562,6 +564,7 @@ var CommentForm = React.createClass({
placeholder="Say something..."
ref="text"
/>
<input type="submit" />
</form>
);
}
Expand Down