mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #31002 from ta1kt0me/call_ajax_without_beforeSend
Call Rails.ajax without beforeSend
This commit is contained in:
commit
ee44c1b6f1
3 changed files with 29 additions and 2 deletions
|
@ -21,7 +21,7 @@ Rails.ajax = (options) ->
|
|||
options.error?(response, xhr.statusText, xhr)
|
||||
options.complete?(xhr, xhr.statusText)
|
||||
|
||||
unless options.beforeSend?(xhr, options)
|
||||
if options.beforeSend? && !options.beforeSend(xhr, options)
|
||||
return false
|
||||
|
||||
if xhr.readyState is XMLHttpRequest.OPENED
|
||||
|
|
27
actionview/test/ujs/public/test/call-ajax.js
Normal file
27
actionview/test/ujs/public/test/call-ajax.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
(function() {
|
||||
|
||||
module('call-ajax', {
|
||||
setup: function() {
|
||||
$('#qunit-fixture')
|
||||
.append($('<a />', { href: '#' }))
|
||||
}
|
||||
})
|
||||
|
||||
asyncTest('call ajax without "ajax:beforeSend"', 1, function() {
|
||||
|
||||
var link = $('#qunit-fixture a')
|
||||
link.bindNative('click', function() {
|
||||
Rails.ajax({
|
||||
type: 'get',
|
||||
url: '/',
|
||||
success: function() {
|
||||
ok(true, 'calling request in ajax:success')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
link.triggerNative('click')
|
||||
setTimeout(function() { start() }, 13)
|
||||
})
|
||||
|
||||
})()
|
|
@ -1,6 +1,6 @@
|
|||
<% @title = "rails-ujs test" %>
|
||||
|
||||
<%= test_to 'data-confirm', 'data-remote', 'data-disable', 'data-disable-with', 'call-remote', 'call-remote-callbacks', 'data-method', 'override', 'csrf-refresh', 'csrf-token' %>
|
||||
<%= test_to 'data-confirm', 'data-remote', 'data-disable', 'data-disable-with', 'call-remote', 'call-remote-callbacks', 'data-method', 'override', 'csrf-refresh', 'csrf-token', 'call-ajax' %>
|
||||
|
||||
<h1 id="qunit-header"><%= @title %></h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
|
|
Loading…
Reference in a new issue