Skip to content

Commit 57c76fa

Browse files
committed
feat: Update notify function to send save-end event and error event
1 parent f365c51 commit 57c76fa

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

common/templates/xblock_v2/xblock_iframe.html

+10-11
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,15 @@
215215
}
216216
return url;
217217
},
218-
notify: () => {
219-
/**
220-
* Used in `studio_view`
221-
*
222-
* TODO: Do nothing for now
223-
* **/
218+
notify: (eventName, data) => {
219+
/**
220+
* Used in `studio_view` to notify events and errors
221+
**/
222+
if (eventName == 'save' && data.state == 'end') {
223+
window.parent.postMessage('save-end', '*');
224+
} else if (eventName == 'error') {
225+
window.parent.postMessage('error', '*');
226+
}
224227
}
225228
};
226229

@@ -267,15 +270,11 @@
267270
}
268271

269272
if ('{{ view_name | safe }}' === 'studio_view') {
270-
// Used when rendering the `studio_view`, in order to intercept and handle the cancel/save button event
273+
// Used when rendering the `studio_view`, in order to intercept and handle the cancel button event
271274
document.querySelector('.cancel-button').addEventListener('click', function() {
272275
event.preventDefault();
273276
window.parent.postMessage('cancel-clicked', '*');
274277
});
275-
document.querySelector('.save-button').addEventListener('click', function() {
276-
event.preventDefault();
277-
window.parent.postMessage('save-clicked', '*');
278-
});
279278
}
280279
}
281280

0 commit comments

Comments
 (0)