1 $(document).on('click', '.selectable', function() {
3 if (!$this.hasClass('multiple')) {
4 $this.closest('.selectable-container').
8 $this.toggleClass('active');
9 }).on('click', '.modal button[data-action-href]', function() {
12 var $modal = $(this).closest('.modal');
13 $modal.find('.modal-error').removeClass('hide').hide();
14 $modal.find('.selectable.active[data-object-uuid]').each(function() {
15 selection.push($(this).attr('data-object-uuid'));
17 data[$(this).data('action-data').selection_param] = selection[0];
18 $.ajax($(this).attr('data-action-href'),
20 type: $(this).attr('data-method'),
22 context: {modal: $modal}}).
23 fail(function(jqxhr, status, error) {
24 if (jqxhr.readyState == 0 || jqxhr.status == 0) {
25 message = "Cancelled."
26 } else if (jqxhr.responseJSON && jqxhr.responseJSON.errors) {
27 message = jqxhr.responseJSON.errors.join("; ");
29 message = "Request failed.";
31 this.modal.find('.modal-error').
32 html('<div class="alert alert-danger">' + message + '</div>').
36 this.modal.find('.modal-error').hide();
37 window.location.reload();