@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.

Signature:
on(type: 'confirm_close', listener: () => void): this;

Parameters#

ParameterTypeDescription
type'confirm_close''confirm_close'
listener() => voidevent listener function
Returns:

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);
}
});