aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2013-12-14 03:30:29 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2013-12-14 03:30:29 -0800
commit068580d4456e881e568de4a4d20a401e87b6c9e1 (patch)
tree5d8e77d8c770f1be5f53bff16f4fe30ebde91aa3 /guides/source
parent12affbe491e4ad7056c7bc1555cf223129cb2745 (diff)
parent02caba2b8617cd8c64927071f48905ca63325ab7 (diff)
downloadrails-068580d4456e881e568de4a4d20a401e87b6c9e1.tar.gz
rails-068580d4456e881e568de4a4d20a401e87b6c9e1.tar.bz2
rails-068580d4456e881e568de4a4d20a401e87b6c9e1.zip
Merge pull request #13316 from JuanitoFatas/working-with-js
Improve document: working with javascript in rails [ci skip].
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/working_with_javascript_in_rails.md20
1 files changed, 15 insertions, 5 deletions
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index 301e0e7e6c..3c04204c29 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -169,7 +169,7 @@ This will generate the following HTML:
</form>
```
-Note the `data-remote='true'`. Now, the form will be submitted by Ajax rather
+Note the `data-remote="true"`. Now, the form will be submitted by Ajax rather
than by the browser's normal submit mechanism.
You probably don't want to just sit there with a filled out `<form>`, though.
@@ -194,7 +194,17 @@ is very similar to `form_for`. It has a `:remote` option that you can use like
this:
```erb
-<%= form_tag('/posts', remote: true) %>
+<%= form_tag('/posts', remote: true) do %>
+ ...
+<% end %>
+```
+
+This will generate the following HTML:
+
+```html
+<form accept-charset="UTF-8" action="/posts" data-remote="true" method="post">
+ ...
+</form>
```
Everything else is the same as `form_for`. See its documentation for full
@@ -299,10 +309,10 @@ The `app/views/users/_user.html.erb` partial contains the following:
The top portion of the index page displays the users. The bottom portion
provides a form to create a new user.
-The bottom form will call the create action on the Users controller. Because
+The bottom form will call the `create` action on the `UsersController`. Because
the form's remote option is set to true, the request will be posted to the
-users controller as an Ajax request, looking for JavaScript. In order to
-service that request, the create action of your controller would look like
+`UsersController` as an Ajax request, looking for JavaScript. In order to
+serve that request, the `create` action of your controller would look like
this:
```ruby