diff --git a/app/assets/javascripts/shared/modal_close_redirect.js b/app/assets/javascripts/shared/modal_close_redirect.js index ad9786519..15c060d03 100644 --- a/app/assets/javascripts/shared/modal_close_redirect.js +++ b/app/assets/javascripts/shared/modal_close_redirect.js @@ -10,13 +10,6 @@ Turbolinks.visit(targetPath); } }); - - $(document).on('ajax:success', 'form[data-action*="modal-close"]', function(_, { form, flash }) { - $(this).closest('.modal').modal('hide'); - if (flash) { - HelperModule.flashAlertMsg(flash, 'success'); - } - }); } $(document).one('turbolinks:load', initModalCloseListeners); diff --git a/app/assets/javascripts/shared/remote_modal.js b/app/assets/javascripts/shared/remote_modal.js index bd4e2745e..bc680e28a 100644 --- a/app/assets/javascripts/shared/remote_modal.js +++ b/app/assets/javascripts/shared/remote_modal.js @@ -9,9 +9,14 @@ animateSpinner(); $.get(ev.currentTarget.getAttribute('href')).then(function({ modal }) { - $(modal).on('shown.bs.modal', function() { - $(this).find('.selectpicker').selectpicker(); - }).modal('show'); + $(modal) + .on('shown.bs.modal', function() { + $(this).find('.selectpicker').selectpicker(); + }) + .on('hidden.bs.modal', function() { + $(this).remove(); + }) + .modal('show'); animateSpinner(null, false); }); }); diff --git a/app/views/access_permissions/partials/_new_assignments_form.html.erb b/app/views/access_permissions/partials/_new_assignments_form.html.erb index 01534a3b5..15f62e1f7 100644 --- a/app/views/access_permissions/partials/_new_assignments_form.html.erb +++ b/app/views/access_permissions/partials/_new_assignments_form.html.erb @@ -10,7 +10,7 @@ <%= t '.title', resource_name: resource.name %> - <%= form_with(model: form_object, url: create_path, method: :post, remote: true, html: { id: 'new-user-assignment-to-project-form', data: { action: 'modal-close' } }) do |f| %> + <%= form_with(model: form_object, url: create_path, method: :post, remote: true, html: { id: 'new-user-assignment-to-project-form', data: { action: 'replace-form', target: '#user_assignments_modal' } }) do |f| %>