diff options
author | Dmytro Vasin <dmytro.vasin@gmail.com> | 2018-04-14 18:56:34 +0300 |
---|---|---|
committer | Dmytro Vasin <dmytro.vasin@gmail.com> | 2018-04-14 19:44:14 +0300 |
commit | e3fcd96dc4b3e51e9b1260a85fe477c2a8901a75 (patch) | |
tree | 42ef9c9b7fd9e810b68ba84c925d2f3a68b27e7e /guides | |
parent | 662ba236d115d3e2152b04dcdefdc0ee6f1f6102 (diff) | |
download | rails-e3fcd96dc4b3e51e9b1260a85fe477c2a8901a75.tar.gz rails-e3fcd96dc4b3e51e9b1260a85fe477c2a8901a75.tar.bz2 rails-e3fcd96dc4b3e51e9b1260a85fe477c2a8901a75.zip |
Fix stoppable events in tests and docs.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/working_with_javascript_in_rails.md | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index b9ea4ad47a..a922bdc16b 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -382,10 +382,9 @@ have been bundled into `event.detail`. 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). ### Stoppable events - -If you stop `ajax:before` or `ajax:beforeSend` by returning false from the -handler method, the Ajax request will never take place. The `ajax:before` event -can manipulate form data before serialization and the +You can stop execution of the Ajax request by running `event.preventDefault()` +from the handlers methods `ajax:before` or `ajax:beforeSend`. +The `ajax:before` event can manipulate form data before serialization and the `ajax:beforeSend` event is useful for adding custom request headers. If you stop the `ajax:aborted:file` event, the default behavior of allowing the @@ -393,6 +392,9 @@ browser to submit the form via normal means (i.e. non-Ajax submission) will be canceled and the form will not be submitted at all. This is useful for implementing your own Ajax file upload workaround. +Note, you should use `return false` to prevent event for `jquery-ujs` and +`e.preventDefault()` for `rails-ujs` + Server-Side Concerns -------------------- |