demarches-normaliennes/app/javascript/manager/fields/features.js

19 lines
443 B
JavaScript
Raw Normal View History

2018-08-09 11:53:59 +02:00
// Administrate injects its own copy of jQuery
/* globals $ */
2018-08-01 11:22:12 +02:00
$(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 }
})
});
});