Skip to content

Commit

Permalink
feat: Update notify function to send save-end event and error event
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Jan 10, 2025
1 parent f365c51 commit 57c76fa
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions common/templates/xblock_v2/xblock_iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,15 @@
}
return url;
},
notify: () => {
/**
* Used in `studio_view`
*
* TODO: Do nothing for now
* **/
notify: (eventName, data) => {
/**
* 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', '*');
}
}
};

Expand Down Expand Up @@ -267,15 +270,11 @@
}

if ('{{ view_name | safe }}' === 'studio_view') {
// Used when rendering the `studio_view`, in order to intercept and handle the cancel/save button event
// 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', '*');
});
document.querySelector('.save-button').addEventListener('click', function() {
event.preventDefault();
window.parent.postMessage('save-clicked', '*');
});
}
}

Expand Down

0 comments on commit 57c76fa

Please sign in to comment.