Skip to content

Commit

Permalink
Merge pull request #40 from jnicklas/optional-jquery
Browse files Browse the repository at this point in the history
Make jQuery support optional
  • Loading branch information
rwjblue authored Mar 30, 2020
2 parents c747ab2 + f2dfc86 commit 3faaa5e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/initializers/ember-cli-rails-addon-csrf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Ember from 'ember';

const { $ } = Ember;

export default {
name: 'ember-cli-rails-addon-csrf',

initialize() {
$.ajaxPrefilter((options, originalOptions, xhr) => {
const token = $('meta[name="csrf-token"]').attr('content');
xhr.setRequestHeader('X-CSRF-Token', token);
});
if(Ember.$ && Ember.$.ajaxPrefilter) {
Ember.$.ajaxPrefilter((options, originalOptions, xhr) => {
const token = Ember.$('meta[name="csrf-token"]').attr('content');
xhr.setRequestHeader('X-CSRF-Token', token);
});
}
},
};

0 comments on commit 3faaa5e

Please sign in to comment.