2 on('click', '[data-toggle-permission] input[type=checkbox]', function() {
4 var keys = ['data-permission-uuid',
5 'data-permission-name',
6 'data-permission-head',
7 'data-permission-tail'];
11 data[attr] = $(this).closest('[' + attr + ']').attr(attr);
12 if (data[attr] === undefined) {
13 console.log(["Error: no " + attr + " established here.", this]);
17 var is_checked = $(this).prop('checked');
23 data: {'link[tail_uuid]': data['data-permission-tail'],
24 'link[head_uuid]': data['data-permission-head'],
25 'link[link_class]': 'permission',
26 'link[name]': data['data-permission-name']},
28 fail(function(jqxhr, status, error) {
29 $(this).prop('checked', false);
31 done(function(data, status, jqxhr) {
32 $(this).attr('data-permission-uuid', data['uuid']);
35 $(this).prop('disabled', false);
39 $.ajax('/links/' + data['data-permission-uuid'],
42 data: {'_method': 'DELETE'},
44 fail(function(jqxhr, status, error) {
45 $(this).prop('checked', true);
47 done(function(data, status, jqxhr) {
48 $(this).attr('data-permission-uuid', 'x');
51 $(this).prop('disabled', false);
54 $(this).prop('disabled', true);