未验证 提交 ee44c1b6 编写于 作者: G Guillermo Iguaran 提交者: GitHub

Merge pull request #31002 from ta1kt0me/call_ajax_without_beforeSend

Call Rails.ajax without beforeSend
......@@ -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
......
(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)
})
})()
<% @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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册