Fix global jQuery usage
This commit is contained in:
parent
8b23cbd272
commit
872e07b5e6
5 changed files with 44 additions and 20 deletions
19
app/javascript/manager/fields/features.js
Normal file
19
app/javascript/manager/fields/features.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Administrate injects its own copy of jQuery, and it is the one
|
||||
// configured by rails to send csrf-token
|
||||
const $ = window.$;
|
||||
|
||||
$(document).on('change', '#features input[type=checkbox]', ({ target }) => {
|
||||
target = $(target);
|
||||
const url = target.data('url');
|
||||
const key = target.data('key');
|
||||
const value = target.prop('checked');
|
||||
|
||||
$.ajax(url, {
|
||||
method: 'put',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({
|
||||
features: { [key]: value }
|
||||
})
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue