Skip to content

Commit b42cfea

Browse files
committed
[fix] Restore ajax calls with CSRF protection
1 parent f72084c commit b42cfea

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

app/assets/javascripts/csrf.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
document.addEventListener('turbolinks:load', function() {
2+
$.ajaxSetup({
3+
beforeSend: function(xhr) {
4+
Rails.CSRFProtection(xhr);
5+
},
6+
});
7+
});

app/assets/javascripts/manage/application.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@
77
//= require_directory ./lib
88

99
function applicationReady() {
10-
$(".selectize").selectize();
11-
$("select[data-bulk-row-edit]").bulkRowEdit();
10+
$('.selectize').selectize();
11+
$('select[data-bulk-row-edit]').bulkRowEdit();
1212
$().bulkRowSelect();
13-
$("body").chartkickAutoReload();
13+
$('body').chartkickAutoReload();
1414
setupDataTables();
1515
setupHighcharts();
1616
$('[data-toggle="popover"]').popover();
1717
$('[data-message-live-preview="textarea"]').messageLivePreview();
1818
setupSimpleMde();
1919
setupEmailEvents();
2020
setupManageForms();
21+
22+
$.ajaxSetup({
23+
beforeSend: function(xhr) {
24+
Rails.CSRFProtection(xhr);
25+
},
26+
});
2127
}
2228

23-
document.addEventListener("turbolinks:load", applicationReady);
29+
document.addEventListener('turbolinks:load', applicationReady);

0 commit comments

Comments
 (0)