mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Fix delete request bug to ensure event listeners are not duplicated
This commit is contained in:
parent
79d017127a
commit
0b4cdf7a69
1 changed files with 7 additions and 2 deletions
|
@ -1507,8 +1507,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
modals.forEach(modal => {
|
||||
const submitButton = modal.querySelector('.usa-modal__submit');
|
||||
const closeButton = modal.querySelector('.usa-modal__close');
|
||||
submitButton.addEventListener('click', function() {
|
||||
pk = submitButton.getAttribute('data-pk');
|
||||
|
||||
// Clone the submit button to remove all existing event listeners
|
||||
const newSubmitButton = submitButton.cloneNode(true);
|
||||
submitButton.parentNode.replaceChild(newSubmitButton, submitButton);
|
||||
|
||||
newSubmitButton.addEventListener('click', function() {
|
||||
pk = newSubmitButton.getAttribute('data-pk');
|
||||
// Close the modal to remove the USWDS UI local classes
|
||||
closeButton.click();
|
||||
// If we're deleting the last item on a page that is not page 1, we'll need to refresh the display to the previous page
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue