Added logic for case when there are NO additional contacts

This commit is contained in:
CocoByte 2024-07-30 19:49:47 -06:00
parent 892c8331b3
commit 9a5b07c79f
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F

View file

@ -649,6 +649,8 @@ function initializeWidgetOnList(list, parentId) {
const contacts = document.querySelectorAll('.field-other_contacts .dja-detail-list dl'); const contacts = document.querySelectorAll('.field-other_contacts .dja-detail-list dl');
if (contacts) { if (contacts) {
contacts.forEach(contact => { contacts.forEach(contact => {
// Check if the <dl> element is not empty
if (contact.children.length > 0) {
const name = contact.querySelector('a#contact_info_name').innerText; const name = contact.querySelector('a#contact_info_name').innerText;
const title = contact.querySelector('span#contact_info_title').innerText; const title = contact.querySelector('span#contact_info_title').innerText;
const email = contact.querySelector('span#contact_info_email').innerText; const email = contact.querySelector('span#contact_info_email').innerText;
@ -658,6 +660,7 @@ function initializeWidgetOnList(list, parentId) {
const listItem = document.createElement('li'); const listItem = document.createElement('li');
listItem.innerHTML = `<a href="${url}">${name}</a>, ${title}, ${email}, ${phone}`; listItem.innerHTML = `<a href="${url}">${name}</a>, ${title}, ${email}, ${phone}`;
bulletList.appendChild(listItem); bulletList.appendChild(listItem);
}
}); });
} }