Skip to content

Commit

Permalink
refactor: Update code to send all events in notify using xblock-event…
Browse files Browse the repository at this point in the history
… message
  • Loading branch information
ChrisChV committed Jan 14, 2025
1 parent 3b2268d commit c05755c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions common/templates/xblock_v2/xblock_iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@
/**
* Used in `studio_view` to notify events and errors
**/
if (eventName == 'save' && data.state == 'end') {
window.parent.postMessage('save-end', '*');
} else if (eventName == 'error') {
window.parent.postMessage('error', '*');
}
window.parent.postMessage({
type: 'xblock-event',
eventName,
data,
}, '*');
}
};

Expand Down Expand Up @@ -273,7 +273,10 @@
// Used when rendering the `studio_view`, in order to intercept and handle the cancel button event
document.querySelector('.cancel-button').addEventListener('click', function() {
event.preventDefault();
window.parent.postMessage('cancel-clicked', '*');
window.parent.postMessage({
type: 'xblock-event',
eventName: 'cancel-clicked',
}, '*');
});
}
}
Expand Down

0 comments on commit c05755c

Please sign in to comment.