mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 14:04:10 +02:00
revise solution to override uswds code instead of deleting it
This commit is contained in:
parent
ff3d18eeae
commit
f608e0b99c
2 changed files with 21 additions and 11 deletions
|
@ -1294,6 +1294,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
* @param {*} pageToDisplay - If we're deleting the last item on a page that is not page 1, we'll need to display the previous page
|
* @param {*} pageToDisplay - If we're deleting the last item on a page that is not page 1, we'll need to display the previous page
|
||||||
*/
|
*/
|
||||||
function deleteDomainRequest(domainRequestPk,pageToDisplay) {
|
function deleteDomainRequest(domainRequestPk,pageToDisplay) {
|
||||||
|
|
||||||
|
// Use to debug uswds modal issues
|
||||||
|
//console.log('deleteDomainRequest')
|
||||||
|
|
||||||
// Get csrf token
|
// Get csrf token
|
||||||
const csrfToken = getCsrfToken();
|
const csrfToken = getCsrfToken();
|
||||||
// Create FormData object and append the CSRF token
|
// Create FormData object and append the CSRF token
|
||||||
|
@ -1348,6 +1352,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
const tbody = document.querySelector('.domain-requests__table tbody');
|
const tbody = document.querySelector('.domain-requests__table tbody');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
|
// Unload modals will re-inject the DOM with the initial placeholders to allow for .on() in regular use cases
|
||||||
|
// We do NOT want that as it will cause multiple placeholders and therfore multiple inits on delete,
|
||||||
|
// which will cause bad delete requests to be sent.
|
||||||
|
const preExistingModalPlaceholders = document.querySelectorAll('[data-placeholder-for^="toggle-delete-domain-alert"]');
|
||||||
|
preExistingModalPlaceholders.forEach(element => {
|
||||||
|
console.log('found one');
|
||||||
|
element.remove();
|
||||||
|
});
|
||||||
|
|
||||||
// remove any existing modal elements from the DOM so they can be properly re-initialized
|
// remove any existing modal elements from the DOM so they can be properly re-initialized
|
||||||
// after the DOM content changes and there are new delete modal buttons added
|
// after the DOM content changes and there are new delete modal buttons added
|
||||||
unloadModals();
|
unloadModals();
|
||||||
|
|
|
@ -5311,17 +5311,14 @@ const cleanUpModal = baseComponent => {
|
||||||
const modalID = modalWrapper.getAttribute("id");
|
const modalID = modalWrapper.getAttribute("id");
|
||||||
const originalLocationPlaceHolder = document.querySelector(`[data-placeholder-for="${modalID}"]`);
|
const originalLocationPlaceHolder = document.querySelector(`[data-placeholder-for="${modalID}"]`);
|
||||||
if (originalLocationPlaceHolder) {
|
if (originalLocationPlaceHolder) {
|
||||||
// DOTGOV
|
for (let attributeIndex = 0; attributeIndex < originalLocationPlaceHolder.attributes.length; attributeIndex += 1) {
|
||||||
// Why is this line here? It seems to be recreating the original placeholder and then adding a
|
const attribute = originalLocationPlaceHolder.attributes[attributeIndex];
|
||||||
// copy of it after that first placeholder, which is netralizing our call of off()
|
if (attribute.name.startsWith('data-original-')) {
|
||||||
// for (let attributeIndex = 0; attributeIndex < originalLocationPlaceHolder.attributes.length; attributeIndex += 1) {
|
// data-original- is 14 long
|
||||||
// const attribute = originalLocationPlaceHolder.attributes[attributeIndex];
|
modalContent.setAttribute(attribute.name.substr(14), attribute.value);
|
||||||
// if (attribute.name.startsWith('data-original-')) {
|
}
|
||||||
// // data-original- is 14 long
|
}
|
||||||
// modalContent.setAttribute(attribute.name.substr(14), attribute.value);
|
originalLocationPlaceHolder.after(modalContent);
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//originalLocationPlaceHolder.after(modalContent);
|
|
||||||
originalLocationPlaceHolder.parentElement.removeChild(originalLocationPlaceHolder);
|
originalLocationPlaceHolder.parentElement.removeChild(originalLocationPlaceHolder);
|
||||||
}
|
}
|
||||||
modalWrapper.parentElement.removeChild(modalWrapper);
|
modalWrapper.parentElement.removeChild(modalWrapper);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue