Skip to content

Commit b19fae1

Browse files
committed
Committing only the xhr changes.
1 parent 7a4c6f4 commit b19fae1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/rails.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@
106106

107107
// Submits "remote" forms and links with ajax
108108
handleRemote: function(element) {
109-
var method, url, data, crossDomain, dataType, options;
109+
var method, url, data, crossDomain, withCredentials, dataType, options;
110110

111111
if (rails.fire(element, 'ajax:before')) {
112112
crossDomain = element.data('cross-domain') || null;
113+
withCredentials = element.data('with-credentials') || null;
113114
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
114115

115116
if (element.is('form')) {
@@ -134,7 +135,7 @@
134135
}
135136

136137
options = {
137-
type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
138+
type: method || 'GET', data: data, dataType: dataType,
138139
// stopping the "ajax:beforeSend" event will cancel the ajax request
139140
beforeSend: function(xhr, settings) {
140141
if (settings.dataType === undefined) {
@@ -150,7 +151,11 @@
150151
},
151152
error: function(xhr, status, error) {
152153
element.trigger('ajax:error', [xhr, status, error]);
153-
}
154+
},
155+
xhrFields: {
156+
withCredentials: withCredentials
157+
},
158+
crossDomain: crossDomain
154159
};
155160
// Only pass url to `ajax` options if not blank
156161
if (url) { options.url = url; }
@@ -274,7 +279,7 @@
274279
element.data('ujs:enable-with', element.html()); // store enabled state
275280
element.html(element.data('disable-with')); // set to disabled state
276281
element.bind('click.railsDisable', function(e) { // prevent further clicking
277-
return rails.stopEverything(e)
282+
return rails.stopEverything(e);
278283
});
279284
},
280285

0 commit comments

Comments
 (0)