From 19afeaf5804b3d6e0738d6a9506235ff50a0497b Mon Sep 17 00:00:00 2001 From: Vasin Dmitriy Date: Wed, 17 May 2017 22:19:52 +0300 Subject: Fix callback in rails ujs --- .../app/assets/javascripts/rails-ujs/features/remote.coffee | 2 +- actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'actionview/app') 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 -- cgit v1.2.3