aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/app
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2017-10-19 09:13:31 -0500
committerGitHub <noreply@github.com>2017-10-19 09:13:31 -0500
commitb7bf70982395ee5fd2e89064f87f268eeddb9d6d (patch)
tree58c025b99fb6c6433fe89ad866556fddc9bacd2f /actionview/app
parent207c37a1ec6cdbe9865d622de9bf0c7e2599bdcc (diff)
parent19afeaf5804b3d6e0738d6a9506235ff50a0497b (diff)
downloadrails-b7bf70982395ee5fd2e89064f87f268eeddb9d6d.tar.gz
rails-b7bf70982395ee5fd2e89064f87f268eeddb9d6d.tar.bz2
rails-b7bf70982395ee5fd2e89064f87f268eeddb9d6d.zip
Merge pull request #29127 from DmytroVasin/rails-ujs-remote-callbacks
Fix callback in rails ujs
Diffstat (limited to 'actionview/app')
-rw-r--r--actionview/app/assets/javascripts/rails-ujs/features/remote.coffee2
-rw-r--r--actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee9
2 files changed, 5 insertions, 6 deletions
diff --git a/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee b/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee
index 852587042c..b3448dabac 100644
--- a/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee
+++ b/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee
@@ -62,7 +62,7 @@ Rails.handleRemote = (e) ->
fire(element, 'ajax:send', [xhr])
else
fire(element, 'ajax:stopped')
- xhr.abort()
+ return false
success: (args...) -> fire(element, 'ajax:success', args)
error: (args...) -> fire(element, 'ajax:error', args)
complete: (args...) -> fire(element, 'ajax:complete', args)
diff --git a/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee b/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee
index a653d3af3d..4d7848e162 100644
--- a/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee
+++ b/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee
@@ -20,13 +20,12 @@ Rails.ajax = (options) ->
else
options.error?(response, xhr.statusText, xhr)
options.complete?(xhr, xhr.statusText)
- # Call beforeSend hook
- options.beforeSend?(xhr, options)
- # Send the request
+
+ unless options.beforeSend?(xhr, options)
+ return false
+
if xhr.readyState is XMLHttpRequest.OPENED
xhr.send(options.data)
- else
- fire(document, 'ajaxStop') # to be compatible with jQuery.ajax
prepareOptions = (options) ->
options.url = options.url or location.href