alter ids for dynamic modal content to avoid name collisions
closes #308
This commit is contained in:
parent
4181b9b6b8
commit
1b2d980971
@ -112,10 +112,23 @@
|
|||||||
if (previousModalContent) {
|
if (previousModalContent) {
|
||||||
previousModalContent.remove();
|
previousModalContent.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modalContent = withPrefixedInputIDs(modalContent);
|
||||||
modalElement.insertBefore(modalContent, null);
|
modalElement.insertBefore(modalContent, null);
|
||||||
setupForm();
|
setupForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withPrefixedInputIDs(modalContent) {
|
||||||
|
var idAttrs = ['id', 'for', 'data-conditional-id'];
|
||||||
|
idAttrs.forEach(function(attr) {
|
||||||
|
modalContent.querySelectorAll('[' + attr + ']').forEach(function(input) {
|
||||||
|
var value = modalElement.id + '__' + input.getAttribute(attr);
|
||||||
|
input.setAttribute(attr, value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return modalContent;
|
||||||
|
}
|
||||||
|
|
||||||
function keyupHandler(event) {
|
function keyupHandler(event) {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
close();
|
close();
|
||||||
|
|||||||
Reference in New Issue
Block a user