@shakrmedia/editor-sdk ShakrEditor > on
ShakrEditor.on() method
confirm_close
event emitted when a user tries to close Shakr Editor while it is saving data.
on(type: 'confirm_close', listener: () => void): this;
Parameters
Parameter | Type | Description |
---|---|---|
type | 'confirm_close' | 'confirm_close' |
listener | () => void | event listener function |
this
Example
Here's an exmaple to use this event properly.
const editor = new ShakrEditor({ ... });
editor.on('confirm_close', () => {
// Show confirmation alert in order to let users know about data loss.
if (window.confirm('Are you sure you wish to close the editor? Any unsaved changes that may exist will be lost.')) {
// After confirmation, force close Shakr Editor.
editor.close(true);
}
});