@@ -298,7 +309,7 @@ requests for `data-remote` elements, by way of the `data-type` attribute.
### Confirmations
You can ask for an extra confirmation of the user by adding a `data-confirm`
attribute on links and forms. The user will be presented a JavaScript `confirm()`
attribute on links and forms. The user will be presented with a JavaScript `confirm()`
dialog containing the attribute's text. If the user chooses to cancel, the action
doesn't take place.
...
...
@@ -323,7 +334,7 @@ you should **not** have `data-confirm` on the form itself.
The default confirmation uses a JavaScript confirm dialog, but you can customize
this by listening to the `confirm` event, which is fired just before the confirmation
window appears to the user. To cancel this default confirmation, have the confirm
handler to return `false`.
handler return `false`.
### Automatic disabling
...
...
@@ -338,9 +349,9 @@ This also works for links with `data-method` attribute.
For example:
```erb
<%=form_withmodel: @article.newdo|form|%>
<%=form_with(model: Article.new)do|form|%>
<%=form.submitdata: {disable_with: "Saving..."}%>
<%=end%>
<%end%>
```
This generates a form with:
...
...
@@ -358,6 +369,7 @@ These introductions cause small changes to `custom events` fired during the requ
NOTE: Signature of calls to UJS's event handlers has changed.
Unlike the version with jQuery, all custom events return only one parameter: `event`.
In this parameter, there is an additional attribute `detail` which contains an array of extra parameters.
For information about the previously used `jquery-ujs` in Rails 5 and earlier, read the [`jquery-ujs` wiki](https://github.com/rails/jquery-ujs/wiki/ajax).
| Event name | Extra parameters (event.detail) | Fired |
You can then submit this token as a `X-CSRF-Token` header for your
Ajax request. You do not need to add a CSRF token for GET requests,
only non-GET ones.
You can read more about about Cross-Site Request Forgery in [Security](https://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf)
You can read more about about Cross-Site Request Forgery in the [Security guide](https://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf).
Other Resources
---------------
Here are some helpful links to help you learn even more: