diff --git a/js/main-updated.js b/js/main-updated.js index 12b3c64..7575dff 100644 --- a/js/main-updated.js +++ b/js/main-updated.js @@ -189,6 +189,16 @@ const MarkitectMain = { }); // Setup section manager event handlers + if (this.sectionManager) { + // The DOM refresh must not depend on the optional debug panel. + this.sectionManager.on('changes-accepted', (data) => { + if (this.debugPanel) { + this.debugPanel.addMessage(`Changes accepted for section: ${data.sectionId}`, 'SUCCESS'); + } + this.updateSectionDOM(data.sectionId); + }); + } + if (this.sectionManager && this.debugPanel) { this.sectionManager.on('sections-created', (data) => { this.debugPanel.addMessage(`Created ${data.count} sections`, 'INFO'); @@ -198,11 +208,6 @@ const MarkitectMain = { this.debugPanel.addMessage(`Edit started for section: ${data.sectionId}`, 'DEBUG'); }); - this.sectionManager.on('changes-accepted', (data) => { - this.debugPanel.addMessage(`Changes accepted for section: ${data.sectionId}`, 'SUCCESS'); - this.updateSectionDOM(data.sectionId); - }); - this.sectionManager.on('changes-cancelled', (data) => { this.debugPanel.addMessage(`Changes cancelled for section: ${data.sectionId}`, 'WARNING'); });