bug fixing
This commit is contained in:
parent
7e753fe4cb
commit
34ab7eec0f
3 changed files with 47 additions and 4 deletions
|
@ -13,7 +13,12 @@ async function loadContent(sectionId, contentFile) {
|
|||
// Find the section and update its content
|
||||
const section = document.getElementById(sectionId);
|
||||
if (section) {
|
||||
// Preserve the close button
|
||||
const closeButton = section.querySelector('.close');
|
||||
section.innerHTML = html;
|
||||
if (closeButton) {
|
||||
section.insertBefore(closeButton, section.firstChild);
|
||||
}
|
||||
console.log(`Successfully updated content for ${sectionId}`);
|
||||
} else {
|
||||
console.error(`Section element not found for ${sectionId}`);
|
||||
|
@ -29,7 +34,11 @@ async function loadContent(sectionId, contentFile) {
|
|||
// Show error message in the section
|
||||
const section = document.getElementById(sectionId);
|
||||
if (section) {
|
||||
const closeButton = section.querySelector('.close');
|
||||
section.innerHTML = `<h2 class="major">Error</h2><p>Could not load content. Please try refreshing the page.</p><p>Error details: ${error.message}</p>`;
|
||||
if (closeButton) {
|
||||
section.insertBefore(closeButton, section.firstChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +46,13 @@ async function loadContent(sectionId, contentFile) {
|
|||
// Load content when the page loads
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
console.log('DOM Content Loaded - Starting content loading');
|
||||
// Map of section IDs to content files
|
||||
// Map of section IDs to content files - only for sections that need external content
|
||||
const contentMap = {
|
||||
'announce': 'announce.html',
|
||||
'date': 'date.html',
|
||||
'showmetheway': 'directions.html',
|
||||
'rsvp': 'rsvp.html',
|
||||
'campinfos': 'campinfos.html',
|
||||
'y2024': 'y2024.html'
|
||||
'campinfos': 'campinfos.html'
|
||||
};
|
||||
|
||||
// Load content for each section
|
||||
|
|
|
@ -396,4 +396,19 @@
|
|||
$main._show(location.hash.substr(1), true);
|
||||
});
|
||||
|
||||
// Add close button functionality
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Add click event listeners to all close buttons
|
||||
document.querySelectorAll('.close').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
// Find the closest article element
|
||||
const article = button.closest('article');
|
||||
if (article) {
|
||||
// Use the existing _hide method
|
||||
$main._hide(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
Loading…
Add table
Add a link
Reference in a new issue